Re: Socket>>accept
Posted by
Daniel Birkinshaw on
Apr 17, 2010; 11:19pm
URL: https://forum.world.st/Socket-accept-tp1839185p2014494.html
On Sat, Apr 17, 2010 at 06:32:22PM +0100, Michael Roberts wrote:
> Hi, i think there is something wrong with listenOn:. I am not sure
> what exactly. the variation below seems to work in Pharo 1.0 on OS X.
>
> | server client |
> server := Socket new.
> server listenOn: 12345 backlogSize: 4.
> server waitForConnectionFor: 600.
> client := server accept.
> client receiveData
> --> 'hello '
>
>
> and from a shell
> echo hello | nc localhost 12345
Confirmed, that works for me. I infer from this that it is illegal to
call accept with a backlogSize of 0. Perhaps this should be checked for
at a higher level so that a meaningful error can be returned?
I was surprised to note that accept returns immediately even if there is
no client connected. Try removing the line "server waitForConnectionFor:
600." in your example. The code still runs but the socket it returns is
in the connected state even though it can't possibly be connected to
anything. Is this behaviour correct? I thought accept was a blocking
call.
I'll look into ConnectionQueue, thanks for the help.
_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users