aaronburro Sup, B 53068 Posts user info edit post |
Alright, this is probably going to sound dumb, but here goes.
I've got to listen for packets and send packets at the same time over the same UDP port. No, I can't send on one port and listen on another, and no, I can't use TCP. I'm getting a damned bind error whenever I try and send, which means I'm doing it wrong, if it can be done. WTF am I doing wrong? I've set all of the sockets to reuse the address/port, but to no avail.
Thx for the help for the newb. 4/23/2007 3:38:40 AM |
joe_schmoe All American 18758 Posts user info edit post |
winsock ? 4/23/2007 5:59:10 AM |
A Tanzarian drip drip boom 10995 Posts user info edit post |
Language? In the .NET languages you should be able to do what you're describing using the same instance of UdpClient. However, I'm not sure that you can send and receive simultaneously, i.e. you can't set the UdpClient to listen for incoming packets and then use the same UdpClient to intermittently send packets. You have to send, then receive, then send, then receive, etc, etc.
You could use two different UdpClients, one send and one receive, both bound to the same port (I think this should work). Or, you could write a send program and a receive program and run them both on the same computer (I know this will work).
Be careful using UdpClient...it has both blocking and threaded calls for send and receive.
-----
Oh, yeah...If you're using Windows, make sure you open the port in the firewall.
[Edited on April 23, 2007 at 8:25 AM. Reason : oh, yeah] 4/23/2007 8:20:12 AM |
BobbyDigital Thots and Prayers 41777 Posts user info edit post |
I don't know what you're doing wrong, but it can be done. UDP is not inherently bidirectional, but the UDP spec does not preclude it either. DNS, for example uses the same send/receive UDP port while other protocols, such as TFTP use different ports for sending and receiving. 4/23/2007 8:21:14 AM |
aaronburro Sup, B 53068 Posts user info edit post |
I'm doin this using java. Now this is making my teeth itch that I can't get it right!
well, i think I found the bug...
[Edited on April 23, 2007 at 8:54 AM. Reason : ] 4/23/2007 8:44:22 AM |
aaronburro Sup, B 53068 Posts user info edit post |
Just in case anyone is curious, the problem was that I called the constructor for the DatagramSocket w/ the port number in it, which caused the socket to bind to the port, which was bad juju. Using null as the constructor argument solved all of this, since my DatagramPackets had to know the port number anyway 4/23/2007 12:33:25 PM |
|