Hello,
I've written a program that provides mIRC-like interface/textchat(using tcp socket) and also with audio-chat(using a UDP socket).
The program is the typical client-server setup.
The thing is, TCP packets are sent and received just fine both in my local network and from clients in the global network.
But when it comes to the UDP connection, only the local packet transfer works O_O
Its about 1000 lines, so I'll copy in the relevant UDP socket snippets :)
this.audioSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint clientEP = new IPEndPoint(IPAddress.Any,this.clientPort);
this.audioSocket.Bind(clientEP);
this.serverEP = new IPEndPoint(IPAddress.Parse(this.textbox_connect.Text),serverPort);
this.audioSocket.BeginConnect(this.serverEP, new AsyncCallback(audioConnectCallback), this.audioSocket);
connDone.WaitOne();
this.textbox_display.Text = ("sending sh*t to: " + serverEP.ToString());
StateObject state_audio = new StateObject();
state_audio.setWorkSocket(this.audioSocket);
state_audio.getWorkSocket().BeginReceive(state_audio.getBuffer(), 0, state_audio.getBufferSize(), 0, new AsyncCallback(audioReceive),state_audio);
private void audioReceive(IAsyncResult asyn)
{
int readBytes = 0;
try
{
StateObject state = (StateObject)asyn.AsyncState;
readBytes = state.getWorkSocket().EndReceive(asyn);
this.waveProvider.AddSamples(state.getBuffer(), 0, readBytes);
this.audioSocket.BeginReceive(state.getBuffer(), 0, state.getBufferSize(), SocketFlags.None, new AsyncCallback(audioReceive), state);
}
catch (Exception ez)
{
MessageBox.Show("audioReceive: " + this.textbox_nick.Text + " " +ez.ToString());
}
}
Not sure what else to say, or if this code says anything at all :( is there anything obvious that I am missing, that would make this work on a local network but not outside it?
Its really wierd because there is no exceptions or anything thrown(on any side) when running, nothing just gets received/sent from/to the client outside.
If there is any gaps just let me know!
Cheers