logo       

simple server?: msg#00061

lang.smalltalk.squeak.beginners

Subject: simple server?

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.

Thanks much,
Don


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise