T
TonyS81
Guest
Hi all,
Im very new to the sockets and UDP /TCP etc, so hopefully this is a simple enough question.
Ive created a method which is recieving UDP messages.
public void UDPListening()
{
UDPClient.BeginReceive(ReceiveBroadcast,new object());
}
private void ReceiveBroadcast(IAsyncResult IAR)
{
IPEndPoint IP = new IPEndPoint(IPAddress.Any, 5555);
byte[] B = UDPClient.EndReceive(IAR, ref IP);
F.ProcessMSG(Encoding.ASCII.GetString(B));
UDPListening();
}
If I send a message to IP on port 5555 this is fine. However when I send it on port 5556 (as i wanted to do a test) it threw the error messsage.
An existing connection was forcibly closed by the remote host
Send code :
public void TransmitMessage(String IPAdd, int Port)
{
IPEndPoint IP = new IPEndPoint(IPAddress.Parse(IPAdd), Port);
byte[] B = Encoding.ASCII.GetBytes("This is my Second Message on Specific IP");
UDPClient.Send(B, B.Length, IP);
}
My question is really in two parts.
I would have assumed that because the send was on port 5556 the receiver would have ignored it or not even seen it. As its set to receive on port 5555. So why did it detect the sent message?
The second part is... What do I do to correct ignore the other port traffic. Or have i got this completely wrong and im not understanding the socket thing too well.
Thank in advance
Tony.
Continue reading...
Im very new to the sockets and UDP /TCP etc, so hopefully this is a simple enough question.
Ive created a method which is recieving UDP messages.
public void UDPListening()
{
UDPClient.BeginReceive(ReceiveBroadcast,new object());
}
private void ReceiveBroadcast(IAsyncResult IAR)
{
IPEndPoint IP = new IPEndPoint(IPAddress.Any, 5555);
byte[] B = UDPClient.EndReceive(IAR, ref IP);
F.ProcessMSG(Encoding.ASCII.GetString(B));
UDPListening();
}
If I send a message to IP on port 5555 this is fine. However when I send it on port 5556 (as i wanted to do a test) it threw the error messsage.
An existing connection was forcibly closed by the remote host
Send code :
public void TransmitMessage(String IPAdd, int Port)
{
IPEndPoint IP = new IPEndPoint(IPAddress.Parse(IPAdd), Port);
byte[] B = Encoding.ASCII.GetBytes("This is my Second Message on Specific IP");
UDPClient.Send(B, B.Length, IP);
}
My question is really in two parts.
I would have assumed that because the send was on port 5556 the receiver would have ignored it or not even seen it. As its set to receive on port 5555. So why did it detect the sent message?
The second part is... What do I do to correct ignore the other port traffic. Or have i got this completely wrong and im not understanding the socket thing too well.
Thank in advance
Tony.
Continue reading...