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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Chris Muller-4
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?

Thanks,
  Chris

Reply | Threaded
Open this post in threaded view
|

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

Igor Stasenko
2008/11/12 Chris Muller <[hidden email]>:

> 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.

Reply | Threaded
Open this post in threaded view
|

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

Gerardo Richarte
In reply to this post by Chris Muller-4
Chris Muller wrote:
> 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:
>  

I don't have an squeak here with me right now, but when you
want to do that on any other language, you need to bind() the
UDP socket to a specific local IP address. That binds the UDP
to just that interface: you'll only get packets from it, and other
applications should be able to bind to the same UDP port on
other interfaces

    richie.