alessaww / oscpack

Automatically exported from code.google.com/p/oscpack
Other
0 stars 0 forks source link

Provide a way to get the local endpoint for a connected socket #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
- What steps will reproduce the problem?

1. Create a UdpTransmitSocket and connect it to a remote endpoint, but don't 
call Bind().
2. Call LocalEndpointFor(), passing the (connected) remote endpoint, and you 
will get an assert because the code assumes the socket should be bound.

- What is the expected output? What do you see instead?

I would expect no assert, and to get the local endpoint.
The goal is to be able to create a UdpReceiveSocket sharing the same local port 
as another UdpTransmitSocket (which is perfectly valid).  However, in order to 
do this, you must be able to determine out what local endpoint (port) to use 
when binding your receiver.

- What version of the product are you using? On what operating system?

OS X 10.9.4, Xcode 5.1.1, oscpack 1.1.0 (the latest version).  I'm using it via 
openFrameworks (the ofxOsc add-on).

- Please provide any additional information below.

I spoke to Ross about this, and he provided me with some rough code to try out. 
 It adds a new method, UdpSocket::LocalEndpointForConnectedRemoteEndpoint(), as 
well as optimizing UdpSocket::LocalEndpointFor(), in the case where you're 
requesting the local endpoint for an already-connected remote endpoint.

I'm attaching a patch that implements this new functionality.  Sorry, it's from 
git, from within the openFrameworks repository...But it should show the 
required changes to three files: ip/UdpSocket.h, ip/posix/UdpSocket.cpp and 
ip/win32/UdpSocketWin.cpp.

Original issue reported on code.google.com by holag...@gmail.com on 26 Aug 2014 at 3:18

Attachments: