Code archives/Networking/InputTCP$

This code has been declared by its author to be Public Domain code.

Download source code

InputTCP$ by schilcote2008
I wrote this function for a remote control command line program I was writing. I suddenly realised it workd exactly like the Input command, halting execution until some data comes over input_stream, which it then returns.
Function InputTCP$(input_stream)
Repeat
;no operation because we're just waiting for something to come up on the TCP stream
Until(ReadAvail(input_stream)) 
ret_val$=ReadLine(input_stream)
Return (ret_val$)
End Function

Comments

Ked2008
This is nothing like the Input command. With the Input command you are able to type something, this just waits for something to arrive on the stream.


TaskMaster2008
The input command wait for data to arrive via the console.

This function waits for it to arrive via a socket.

It is similar functionality.


Ked2008
It should be titled WaitTCP, so it isn't so misleading. You aren't doing any inputting, you are just waiting.

BTW, I think the variables are incorrect inside the function. "remote_stream" should be "input_stream".


schilcote2009
Wow, this is still the most recent piece of networking code!


xtremegamr2009
This looks OK. The only problem that I can see with this, though, is that your program will stop until it receives input from the stream.

If you are running a server that serves multiple clients at the same time (which most servers do ;) ), this would be a BIG problem.


schilcote2009
Yeah, it's for 1 on 1 communications. It was originally designed for a program called Rampancy that I used to mess up my schools computers, or more precisely Remote Rampancy, a version designed to allow me to mess up my schools computers over the weekends.

The function was actually very very helpful, because all you have to do is replace every print with a remote_print, and every input with a remote_input. Press ctrl-r twice and put a TCP server thing at the top and your program has perfect remote functionality.


Code Archives Forum