[MUD-Dev] OT: Socket programming - platform specific

Jon A. Lambert jlsysinc at ix.netcom.com
Sat Jan 24 14:48:51 CET 1998


On 23 Jan 98 at 7:57, Chris Gray wrote:
> [Jon Lambert:]
> 
> :Win32s,Win95 and WinNT sockets programming is virtually identical to
> :Unix BSD sockets.
> 
> Nod. Socket programming experience, at least at the level normally needed
> for MUDs, should be interchangeable between UNIX and Win32. The *only*
> Windows program I've done was to port my ToyMUD server to it, and the
> changes were small (mostly involving the points Jon has mentioned about
> the WSAStartup and WSAGetNextError stuff).
                           ^^^^
<heh> I wish I had the above function. It sure would make debugging
easier.  Sort of a kernel precognition function. ;)

> I did find that WinSock is
> a bit pickier than UNIX - it cared about a wrongly initialized family in
> an address, whereas UNIX didn't. The one issue I did not manage to resolve
> is that of shutdown - a control-C typed in the shell window running the
> server creates a thread in the server process, but does *not* interrupt
> any currently executing WinSock call. So, using that technique to shut
> down your server isn't fully satisfactory. However, WinSock seems to
> silently shorten the waits on 'select' to about 10 seconds, so if you
> have a 'ShutDown' flag which is checked in your main idle loop, you'll
> end up shutting down within 10 seconds of the control-C.

A possible solution is to install a SIGINT handler and from within it
call WSACancelBlockingCall() followed by WSACleanup().  It should cancel 
outstanding Select()'s.   

--
--/*\ Jon A. Lambert - TychoMUD     Internet:jlsysinc at ix.netcom.com /*\--
--/*\ Mud Server Developer's Page <http://www.netcom.com/~jlsysinc> /*\--
--/*\   "Everything that deceives may be said to enchant" - Plato   /*\--



More information about the mud-dev-archive mailing list