I think netType determines the arguments to socket(), not to bind(). Currently the options are TCP and UDP, which sounds irrelevant to what you're after. There's currently no way to choose the address that should be listened at, much less the specific interface that should be used.
If you want this enough, it seems perfectly reasonable to add something like #bindToAddress:port: to Socket, and then to add the corresponding stuff to SocketPlugin and to sqUnixNetwork.c. The method might look like:
bindToAddress: aByteArray port: anInteger "bind this socket to the given address and port. all-0's and 0 may be specified, respectively, if the caller doesn't care" <primitive: 'bindToAddress' module: 'SocketPlugin'> ^nil
Then you need to add a platform-independent version of the primitive to SocketPlugin, do "SocketPlugin translate", and add the Linux-specific version to sqUnixNetwork.c. Of course, you need the source files for the Unix VM, too -- Ian Piumart's version 2.8pre5 appears to be the one to go for right now.
So, it's doable, if a fair bit of time is available. :|
-Lex
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
After an admittedly cursory examination of Socket, I see only the comment of:
The netType parameter is platform dependent and can be used to encode both the protocol type (IP, Xerox XNS, etc.) and/or the physical network interface to use if this host is connected to multiple networks. A zero netType means to use IP protocols and the primary (or only) network interface.
in Socket>>primSocketCreateNetwork:type:receiveBufferSize:sendBufSize:semaIndex:
Has anyone done any work to document how this works for the various platforms, or try to make this a little more portable?
Specifically, I need this to bind to a particular interface on a Linux box for my ISP.
It looks like sqUnixSocket.c ignores that parameter, creating an INADDR_ANY socket every time.
-- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
squeak-dev@lists.squeakfoundation.org