Sockets and Multiple-connection servers

Scott A Crosby crosby at qwes.math.cmu.edu
Tue Mar 12 02:12:23 UTC 2002


On Mon, 11 Mar 2002, Derrick Coetzee wrote:

> Somewhat a newbie question, somewhat a design question... is there any
> easy way to simply open a server on a port and have it return a Socket
> object for each new connection, each of which can be then be passed on

Yes.. You create a socket to listen on a port, and then accept
connections. When accepting connections, you get a socket back.

I did this in my network library about 6 months ago.

> to a separate thread for handling as it continues to wait for new
> connections (similar to popular models in Java or MFC Sockets)? Is
> there a good reason not to use this model?

I also did this in the first version of my network library.

But, you may be better off not multithreading, but rather scanning each
socket. Multithreading is semi-expensive on squeak.. Lightweight, but it
may be faster to, for example, have one thread scan all of the sockets
than try to trust multithreading like this.

Scott





More information about the Squeak-dev mailing list