G
Guest
Can anyone tell my what is wrong with this snippet of code?
//Creates a UdpClient for reading incoming data.
UdpClient receivingUdpClient = new UdpClient();
//Creates an IPEndPoint to record the IP Address and port number of the sender.
// The IPEndPoint will allow you to read datagrams sent from any source.
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.101"), 11000);
try
{
// Blocks until a message returns on this socket from a remote host.
ERROR at this line ---------->>> Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
Console.WriteLine("This is the message you received " +
The ERROR I receive is:
System.Net.Sockets.SocketException: An invalid argument was supplied
at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
at System.Net.Sockets.UdpClient.Receive(IPEndPoint& remoteEP)
TIA,
Cory Nemelka
//Creates a UdpClient for reading incoming data.
UdpClient receivingUdpClient = new UdpClient();
//Creates an IPEndPoint to record the IP Address and port number of the sender.
// The IPEndPoint will allow you to read datagrams sent from any source.
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.101"), 11000);
try
{
// Blocks until a message returns on this socket from a remote host.
ERROR at this line ---------->>> Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
Console.WriteLine("This is the message you received " +
The ERROR I receive is:
System.Net.Sockets.SocketException: An invalid argument was supplied
at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
at System.Net.Sockets.UdpClient.Receive(IPEndPoint& remoteEP)
TIA,
Cory Nemelka