asUDP :  schmittMachine support schmittMachine Support Home
Questions related to the asUDP Xtra 
Port Information
Posted by: dh ()
Date: April 10, 2007 02:38AM

Hi,

I've tried out the asUDP Xtra and it works really well. There is one feature that keeps me from being able to use it, though, and that is being able to retrieve the port number that is allocated for sending messages. Basically, the Xtra can't set up two-way communication through a router right now because you don't have this information. You need to listen and send on the same port for that to work (otherwise the server you are connecting to can't send messages back, as your listening port is mapped arbitrarily by the router).

Is there an undocumented way to do this using asUDP? Or perhaps is it simple to add? (If you are willing to open-source the Xtra, I would be happy to make the changes myself.)

Thanks

Options: ReplyQuote
Re: Port Information
Posted by: antoine schmitt ()
Date: April 10, 2007 10:47AM

Hi,
interesting problem.
If I made the portNumber of the sending endpoint public, how would that solve your router problem actually ?

Options: ReplyQuote
Re: Port Information
Posted by: dh ()
Date: April 11, 2007 01:24AM

Here's what we can do then:

Let's say my IP on the local network is 192.168.1.2, and I am able to send from port 56000. My router will remap this port to a certain port on the router say port 22222 on the router's IP, say 234.1.1.1

When the server (outside the network) I want to communicate with receives a message from my computer, the message will show up as from port 22222 of 234.1.1.1 (the router information). If I am also listening on that port, the server can simply reply to that IP on that port and I will get all the messages. In this way, we can establish 2-way communication through a router.

The port that you send on is the only reliable port for the server outside to reply to. Imagine if I send a message on my local port 56000, as above, but listen on local port 32000, for example (this is the situation with the Xtra currently). The server can't reliably determine how to get to my local port 32000, even after I've sent it a message from port 56000. It only knows 1 port reliably: the one from which it received a message.

It's a lot easier to explain with a diagram, but I hope that clears it up a bit.

Options: ReplyQuote
Re: Port Information
Posted by: antoine schmitt ()
Date: April 11, 2007 10:47AM

Hello,
that's what I thought indeed. Actually the sendport information is not available, since the sending port is allocated by the system (I use the PORT_ANY kind of constants to allocate the sending port).

I propose to add a function to the Xtra to allow lingo to optionnally determine the sending port. Something like:
setSendPort(integer portNumber)

If this function is not called, then the sending port is allocated like before (randomly). If it is called, then all further calls to sendBytes will use this port. And calling setSendPort(VOID) will again make the Xtra use a random port.

Would this work for your needs do you think ?

Options: ReplyQuote
Re: Port Information
Posted by: dh ()
Date: April 12, 2007 12:25AM

That would definitely work, and if the sending port information is not available that's the only way to go. Thanks a lot!

Options: ReplyQuote
Re: Port Information
Posted by: antoine schmitt ()
Date: April 12, 2007 10:39AM

I'll try to implement this asap, but I'm a bit overloaded right now, so don't expect it before a couple of weeks... Sorry about this. I'll post here when it is available.
Cheers !



Edited 1 time(s). Last edit at 04/12/2007 03:54PM by antoine schmitt.

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.