Mantis - Croquet
Viewing Issue Advanced Details
2986 Hedgehog major always 02-20-06 23:14 04-21-06 07:30
howardstearns  
andreas  
normal  
resolved  
fixed  
none    
none  
0002986: apple macintosh can be master or participant, but not both
I can run croquet or demo master on a Mac, and then run a participant to that master on a Windows box on the same LAN.

And vice versa.

But I when I run a master on the Mac, I can't run the corresponding participant from the same machine.
(I can run master and participant on the same Windows box.)
related to 0003306resolved mpm connection closed while waiting for data 
 SocketExtensions.cs [^] (23,783 bytes) 03-13-06 23:19
 ContactPointReusePort.1.cs [^] (1,504 bytes) 03-13-06 23:19
 ContactPointReusePort.2.cs.zip [^] (1,070 bytes) 04-19-06 15:54

Notes
(0004447)
howardstearns   
03-13-06 23:20   
Summary: fixed with the attached changesets, which require DPR's VM. The problem was lack of support for SO_REUSEPORT.
   --------------------------------
When there are multiple Harnesses, there are multiple instances of TContactPoint, and each of these opens a socket at the same address/port.

It ought to be possible to arrange for this by using Socket>>setOption:value: for SO_REUSEPORT (and possibly also requiring SO_REUSEADDR). Alas, in the 3.8.4 vm source tree, neither platforms/unix/plugins/SocketPlugin/sqUnixSocket.c nor platforms/win32/plugins/SocketPlugin/sqWin32NetNet.c have SO_REUSEPORT in their list of allowable socket options. In fact, sqUnixSocket.c explicitly disallows it:

# if 0 /*** deliberately unsupported options -- do NOT enable these! ***/
  { "SO_REUSEPORT", SOL_SOCKET, SO_REUSEPORT },
/*omit other disallowed options */
#endif

This isn't hurting us on Windows, which seems to allow address/port reuse regardless of what you want.

Dave Reed's SocketPlugin defines a bunch of new functions, including one that does an end run around the above restriction:

/*
  set the SO_REUSEADDR, SO_REUSEPORT options for the socket.
*/
void sqSocketSetReusable (SocketPtr s)
{
  int err;

  if (!socketValid(s)) return;
  /* on some platforms SO_REUSEADDR and SO_REUSEPORT are different. Set both */
#ifdef SO_REUSEADDR
  err = setsockopt(SOCKET(s), SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
  if(err < 0) {
    interpreterProxy->success(false);
    return;
  }
#endif
#ifdef SO_REUSEPORT
  err = setsockopt(SOCKET(s), SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
  if(err < 0) {
    interpreterProxy->success(false);
    return;
  }
#endif
}

http://atsosxdev.doit.wisc.edu/croquet/SqueakNetX.zip [^] has:
  the binary VM for PC (built by DPR)
  the binary VM and Mac (built by Josh), and
  the source that DPR gave us.
I'll upload a new version with Josh's Mac source soon, so that we'll have everything together on this ticket.

To use this, you need the attached SocketExtension.cs from DPR.

Finally, the attached ContactPointReusePort.cs actually uses the new #setReuseable in TContactPoint>>initialize.

This whole combination (SocketExtensions.cs + ContactPointReusePort.cs + DPRs VM) has been tested successfully on both Windows and Mac over beta 2. (Testing was actually done in conjunction with the changesets attached to 2987 and 3297. That shouldn't matter....)
(0004760)
howardstearns   
04-19-06 15:57   
Fixed on Mac with ContactPointReusePort.2.cs (Note the .2).
Requires Mac VM 3.8.12beta3U and Croquet-Kernel-ar.25.
(I'm not set up for testing Linux.)