Friday, March 03, 2006

more sb-win32-sockets

I've now cleared most of the WARNINGs and STYLE-WARNINGs from the win32 port of sb-bsd-sockets. You can download the reults here. I'm still having fits with a piece of code that initializes the windows sockets subsystem.

For some unknown reason, on windows, you have to run WSAStartup() in your application before you make any calls to networking APIs, or Windows gives you the cold shoulder. Unix isn't so demanding, so I'm hard-pressed to figure out why Windows has to be different. In any case, it is, and so I have to deal with it. It was suggested that I call the function in the initialization of a special.

In Lisp-speak, this is a dynamic, as opposed to lexical variable. The code looks something like:

(defvar *wsa-is-initialized* (wsa-startup ...))

Of course, this doesn't work for me. wsa-startup is in the package sb-bsd-sockets-internal, while the code you are seeing is in the sb-bsd-sockets package. While the same file is sprinkled with internal socket functions, my wsa-startup functions get a nasty ERROR from the compiler. I am assuming that this has to do with the whole eval-when business that I must claim I have absolutely no clue what it is really doing.

It was a package export issue. I wasn't exporting the wsa-startup symbol from the internals package. This was confusing because I thought I was doing the right thing by prefacing it with win32sockint:wsa-startup. It turns out this only works for exported symbols. For unexported symbols, use two colons. win32sockint::wsa-startup. Thanks go to the #lisp crowd for the help on that one. At least you CAN get to the symbol. I was becoming more discontent with C++'s whole public/protected/private pseudo-encapsulation, and Lisp has only solidified that view.


Post a Comment

<< Home