Squeak listening to specific IP Addresses?

Ian Piumarta ian.piumarta at inria.fr
Tue Jan 20 20:19:48 UTC 2004


Hi Andreas,

On 20 Jan 2004, at 20:41, Andreas Raab wrote:
>
> Someone with a bit more socket knowledge should chime in here but it 
> seems
> to me that this almost cries for a primitive doing the equivalent to 
> BSD's
> bind() call - e.g., assign a local address and port to a socket. So 
> wouldn't
> it be easier just to expose something like:
>
> Socket>>bindTo: localAddress port: localPoirt
>
> rather than trying to put all of this information in all of the varying
> places?

This is already _precisely_ what aSock listenOnPort: aPort backlogSize: 
nConn interface: anAddr does.  Cutting out the irrelevant 
implementation noise, the body of the prim contains

   saddr.port = aPort;
   saddr.addr = anAddr;
   bind(aSock, saddr);
   listen(aSock, nConn);

(nothing more, nothing less).  IOW, the only difference between the 
prim and bind() is that the prim goes on to perform the listen() as 
well, since you're pretty much guaranteed to want to do that after 
binding the address.

FWIW, the only difference between that and the "old" listenOn: 
primitive is that the old one uses INADDR_ANY for the interface address 
(which causes the socket to be bound to the given port on all available 
local interfaces).

Cheers,
Ian




More information about the Squeak-dev mailing list