J
Jessi_ca
Guest
Hello,
i have a problem with my udp-Client.
my code looks like this:
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDPClient
{
class Program
{
static void Main(string[] args)
{
//Creates a UdpClient for reading incoming data.
UdpClient receivingUdpClient = new UdpClient(51000);
//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.Any, 0);
try
{
//receivingUdpClient.Connect(RemoteIpEndPoint);
// Blocks until a message returns on this socket from a remote host.
Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
Console.WriteLine("This is the message you received " +
returnData.ToString());
Console.WriteLine("This message was sent from " +
RemoteIpEndPoint.Address.ToString() +
" on their port number " +
RemoteIpEndPoint.Port.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
when i send udp Packages over the colasof packetplayer or with packetsender i receive nothing and my consol stay empty.
any suggestions what could be the reson for it?
Thanks Jessi
Continue reading...
i have a problem with my udp-Client.
my code looks like this:
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDPClient
{
class Program
{
static void Main(string[] args)
{
//Creates a UdpClient for reading incoming data.
UdpClient receivingUdpClient = new UdpClient(51000);
//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.Any, 0);
try
{
//receivingUdpClient.Connect(RemoteIpEndPoint);
// Blocks until a message returns on this socket from a remote host.
Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
Console.WriteLine("This is the message you received " +
returnData.ToString());
Console.WriteLine("This message was sent from " +
RemoteIpEndPoint.Address.ToString() +
" on their port number " +
RemoteIpEndPoint.Port.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
when i send udp Packages over the colasof packetplayer or with packetsender i receive nothing and my consol stay empty.
any suggestions what could be the reson for it?
Thanks Jessi
Continue reading...