开发者

C# udpclient/udp socket -- working locally but not on global addresses

I have a very annoying problem. I have a mIRC/Skype application, meaning chatroom with text and voice. The text & chatroom stuff goes through TCP and works flawlessly, while the UDP only relays recorded data to other connected clients.

Between two clients on my home network, audio transfer works fine. But against a global client, the server will niether receive packets from him, or he will receive packets from the server.

Here's an example:

Server is using udp socket while client is using udpclient, but the result is the same anyway and it works locally too..

server global ip: 222.222.222.222 server local ip: 192.168.2.3 server port: 9999

client global ip: 111.111.111.111 client local ip: 192.168.0.100 client port: 8888

The se开发者_如何学Pythonrver *binds its socket to 192.168.2.3 : 9999 *receives from 111.111.111.111 : 8888 *sends to 111.111.111.111.111 : 8888

the client *binds its socket to 192.168.0.100 *receives from 222.222.222.222 : 9999 *sends to 222.222.222.222 : 9999

...you get what I mean. I have no idea why the data dosn't get through. I've tried sending/receiving on port 53 (for both client and server) and that shouldn't even be necessary right? I mean traffic should go through anyway (just like it does with games like call of duty) and no there is no windows firewall active, only router in that case.

the client/server uses connect() each other, not receiveFrom/sendTo. I tried using that too but no difference.

I get no exceptions or anything either so its impossible to debug :(

What could possibly be the reason? Consider the fact it works locally but not globally; I do agree it really sounds like a firewall issue, but as I'e described above I dont see how thats applicable in my scenario, and I tried on port 53 and other open ports..

Cheers :)

EDIT: its quite alot of code, but if necessary I can copy it in


You can't broadcast UDP to the entire internet (I assume this is what you mean by 'global') - it will only work within the subnet of the machine issuing the broadcast. This is why it works locally but not with the remote machines.

You might want to consider using IP Multicast instead:

http://en.wikipedia.org/wiki/IP_Multicast

That said you may also have problems with that as some routers (that you have no control over) will not allow the multicast packets to be forwarded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜