Problems with sockets with 3.6 Carbon VM?

Phil Hargett hargettp at mindspring.com
Wed Oct 8 00:19:04 UTC 2003


Okay, so a few weeks ago I brought up a potential issue with Sockets on 
the Mac OS X Carbon VM, and, unfortunately, I couldn't rule out my own 
errors from being the cause.

I've now rebuilt the VM from CVS, just after John McIntosh's 
announcement of a new VM.  What I've found is that using 2 different 
SocketPlugin's have different effects, causing the same Smalltalk code 
to behave differently.  In one case, the code appears to do it's job; 
in the other, it does not.

Using the Project Builder project found in CVS, the Mac OS Carbon VM 
uses sqUnixSocket.c for the SocketPlugin; the file sqMacNetwork.c is 
not included in the build.  After building the VM with the defaults 
(and following the instructions found in CVS), I then ran the following 
snippet of code to open a socket:

	machine := #(127 0 0 1).
	port := 5132.
	socket := Socket newTCP.
	socket connectTo: machine port: port.
	socket semaphore wait.

On the receiving end (in the same VM, just another process):

	serverSocket semaphore wait.
		serverSocket isConnected
			ifTrue: [peerSocket := serverSocket accept.
					peerSocket isConnected: ["Do stuff with this new connection"].

What I've discovered is that in the VM built with sqUnixSocket.c (built 
by default), is that although the waiting receiver does return from the 
Socket>>semaphoreWait call, it never receives a connected socket, so it 
just spins endlessly on the Socket>>semaphoreWait call.

When I build with sqMacNetwork.c instead (*not* the default), a 
connected socket is returned from the Socket>>accept call, and my code 
continues processing the connection.

So...am I writing my Smalltalk code incorrect?  Or is there something 
wrong with the Project Builder project, that it should be using 
sqMacNetwork.c instead of sqUnixSocket.c when building the Carbon VM?  
Or is there something up with sqUnixSocket.c?  Something else...perhaps 
a problem with semaphore handling?

Don't know, although I've eliminated problems with my build process 
(followed instructions), source code used for the build (pulled from 
CVS this week), and tested my code in a working VM to ensure it's not 
just a fluke.

Any insight?



More information about the Squeak-dev mailing list