[squeak-dev] Socket - reading UDP only from a specified interface

Igor Stasenko siguctua at gmail.com
Wed Nov 12 18:08:47 UTC 2008


2008/11/12 Chris Muller <ma.chris.m at gmail.com>:
> Hi all!  Does anyone know how #receiveUDPDataInto: decides which
> network interface to read from?
>
> I want to read UDP data only from a particular interface, the only
> reference to this subject I could find:
>
>  http://lists.squeakfoundation.org/pipermail/squeak-dev/2003-September/065912.html
>
> seems to indicate to send #primSocket:connectTo:port: to the reading
> socket as a unorthodox way to force-set a particular interface..?
> Will this work or is there a better way?
>

Wait, if you want to receive data from particular interface, then bind
it to this interface.
The connect() for UDP socket only installs the 'other end' address, so
you can call
send/recv to send and receive datagrams only to/from designated
address instead of sendTo/recvFrom.
Im not sure about following: when you call connect() a system also may
automatically pick an interface which having a route to specified
address, if socket is not already bound, or even rebind it to right
iface.

A windows port always using recvFrom for UDP sockets, so i don't see a
practical need in calling connect() for UDP socket, unless you want to
listen only for particular host:port (but recvFrom ignoring it AFAIK,
recv is not).
I'm also checked, that in windows during execution of
primitiveSocket:receiveUDPDataBuf:start:count:
a socket is bound to a default interface/port only in case, if it
wasn't bound previously.

> Thanks,
>  Chris

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list