Replying over a socket

Phil Davis davis.phil at comcast.net
Mon May 9 19:34:52 EDT 2005


Hi Scott -

Wherever you write data to an app that's going to "read for 1 line", try 
terminating your text with a CR. Maybe that will help.

Phil Davis


Scott Slaugh wrote:
> I am trying to set up a program where a client requests some information 
> from a server, which is then sent back to the client over the same socket. I 
> tried using this script in the server:
> 
> on startListen
> accept connections on port 8080 with message newRequest
> end startListen
> 
> on newRequest theSocket
> read from socket theSocket for one line
> answer it
> write "message received" to socket theSocket
> close socket theSocket
> end newRequest
> 
> In the client, I put this in a button:
> 
> on mouseUp
> open socket to "1.1.1.1:8080 <http://1.1.1.1:8080>"
> write "some request" to socket "1.1.1.1:8080 <http://1.1.1.1:8080>"
> read from socket "1.1.1.1:8080 <http://1.1.1.1:8080>" for one line
> answer it
> close socket "1.1.1.1:8080 <http://1.1.1.1:8080>"
> end mouseUp
> 
> However, the above script does not work. I end up just getting to blank 
> answer boxes on both machines after the sockets time out. I would really 
> like to be able to have my request and response go out over the same socket. 
> Additionally, I would like the client handler to pause until the response is 
> received, since it is acting as a request command. Has anyone done anything 
> like this, or know what I need to do to get this working?
> 
> Scott Slaugh
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 



More information about the use-livecode mailing list