[Newbies] simple server?

Michael van der Gulik mikevdg at gulik.co.nz
Mon Nov 12 04:53:45 UTC 2007

Don McLane wrote:
> I'm trying to learn to write network objects in squeak.  I read the
> chapter "Networking Squeak" by Parsia, Kerimbaev, and Spoon, from Mark
> Guzdials book.  But I wanted to start at a more basic level.
> My first attempt is to write the simplest possible server.  This server
> should wait for a connection, then print the first line sent to it,
> finally close.  Unfortunately, it gets a "primitive failed" error.  I
> got the same result on XP and Vista.  Here's my code:
> | serverSocket connectionSocket |
> Socket initializeNetwork.
> serverSocket := Socket newTCP.
> serverSocket listenOn: 8080.
> connectionSocket := serverSocket accept.
> Transcript show: (connectionSocket upToAll: String crlf).
> connectionSocket close.
> serverSocket close.
> I found some old code for the PWS and looked around.  It makes a
> ServerSocket object, but I can't find that class in my image (3.9-7067).
> If I do get a server socket to return a connection socket, is there a
> way to convert that socket into a SocketStream?
> Can anyone get me un-stuck?  I've been trying to get past this for a
> couple evenings now.
Hi Don.

You'll be wanting to do:
ss := SocketStream on: serverSocket.

I would recommend looking at a simple network service. One I can think
of is REPLServer, which is a telnet server, but there may be simpler
ones out there for e.g. HTTP.

Also, if you want faster help, I recommend joining the #squeak IRC channel.


More information about the Beginners mailing list