Simple TCPServer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Simple TCPServer

squeakman
Hello List,

I am writing a simple TCPServer, the stripped down code that
demonstrates the problem is shown below in the #start method.

I exercise the code by executing the #start method from one workspace
and then running the "client" code from another  workspace. See below
for client code.

The line with the comment "*** THIS LINE ***" must be included to make
this work but I cannot understand why.

If I comment that line out then the client just hangs and eventually
times out with a debugger.  When I terminate the client process then the
server gets control and proceeds.

The code works with this magic line included but why?

Thanks for any clues,
Frank


----------------------------------------
Here is the client code that I run from a workspace:

|req |
req := HttpRequest method: 'GET' url:
'http://localhost:6679/status=001&transId=118'.
req  execute.


----------------------------------------------
Here is the #start method in myTCPServer :

start

        | socket childSocket  connection stream  in |
        socket  := SocketAccessor newTCPserverAtPort: 6679.
        socket  listenFor: 2.

        childSocket := nil.
        childSocket := socket accept.

        "set up a stream on a two-way connection."
        connection := ExternalConnection new
                input: childSocket;
                output: childSocket.
        stream := connection readAppendStream.
        stream lineEndTransparent.

        in := stream through: Character cr.     "*** THIS LINE ***
        (HttpResponse code: '200') writeOn: stream.

        "Close the stream and the parent socket."
        stream close.
        socket close.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc