Hi,

I'm currently working on a chapter about Sockets for the Pharo by example book.
I'm half way, though there is more material than what is on the pharo 
collabor-active book.
It's a pitty, that pharo by example and the collaborative book aren't linked.

Any way, I'll be happy ot send what I have written to anyone who request it.

Noury

On 29 août 2010, at 23:05, Sean P. DeNigris wrote:

> 
> The description of sockets at
> http://book.pharo-project.org/book/networking/Socket/ is:
> 
> Socket is one of the main networking classes. You can create a new TCP
> socket with the message #newTCP.
>> 
>> This example creates a TCP socket and puts it into listening mode. After a
>> client has connected, it reads data from the socket.
>> 
>> | server client |
>> server := Socket newTCP.
>> server listenOn: 12345 backlogSize: 4.
>> server waitForConnectionFor: 600.
>> client := server accept.
>> client receiveData
>> 
> 
> Huh?!  It looks like half the code in this snippet belongs on the server,
> and the other half on the client.  I tried:
>  Server doit:
>    server := Socket newTCP.
>    server listenOn: 12345 backlogSize: 4.
>    server waitForConnectionFor: 600.
>  Client doit:
>    server := Socket newTCP.
>    server listenOn: 12345 backlogSize: 4.
>    server waitForConnectionFor: 600.
>    client := server accept.
>    client receiveData.
> but the server just hung forever.
> 
> After flopping around for a while, and checking the swiki, it seemed to be
> listenOn:backlogSize: that was the problem.  Everything went well with:
>  Server DoIt:
>    server := Socket newTCP.
>    server listenOn: 8080.
>    server waitForConnectionFor: 600.
>    server sendData: 'Hello from the server'
>  Client PrintIt:
>    client := Socket newTCP.
>    client connectTo: (NetNameResolver localHostAddress) port: 8080.
>    client receiveData.
> 
> Anyway, I'd like to have this be clearer, but my knowledge is very basic. 
> Also, the class comment for socket reads "...Sockets are the lowest level of
> networking object in Squeak and are not normally used directly..." so is
> this where we want to direct people first?
> 
> Thanks.
> Sean
> -- 
> View this message in context: 
> http://forum.world.st/Sockets-in-Pharo-CollaborActive-Book-tp2399361p2399361.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
> 
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Noury



_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to