L
Lloyd Dupont
I think Vista might be the culprit....
Anyway, could anyone share with me how to send some data over UDP and
recieve it?
Now it's not working, and I have no clue if it's the sending or recieving or
both which fails....
Anyway I have simple code like that:
=== send ====
public void Send(byte[] data, IPEndPoint to)
{
using (Socket sock = new Socket(to.AddressFamily, SocketType.Dgram,
ProtocolType.Udp))
sock.SendTo(data, SocketFlags.None, to);
}
=== recieve ===
void Receiving()
{
byte[] rbuf = new byte[1 << 14];
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp))
while (true)
{
EndPoint rep = new IPEndPoint(IPAddress.Any, 0);
int read = sock.ReceiveFrom(rbuf, ref rep);
Recieved(rbuf, read, rep);
}
}
void Recieved(byte[] buf, int nRead, EndPoint where)
{
Console.WriteLine("Recieved {0} byte(s) from {1}", nRead, where);
}
===========
Anyway, could anyone share with me how to send some data over UDP and
recieve it?
Now it's not working, and I have no clue if it's the sending or recieving or
both which fails....
Anyway I have simple code like that:
=== send ====
public void Send(byte[] data, IPEndPoint to)
{
using (Socket sock = new Socket(to.AddressFamily, SocketType.Dgram,
ProtocolType.Udp))
sock.SendTo(data, SocketFlags.None, to);
}
=== recieve ===
void Receiving()
{
byte[] rbuf = new byte[1 << 14];
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp))
while (true)
{
EndPoint rep = new IPEndPoint(IPAddress.Any, 0);
int read = sock.ReceiveFrom(rbuf, ref rep);
Recieved(rbuf, read, rep);
}
}
void Recieved(byte[] buf, int nRead, EndPoint where)
{
Console.WriteLine("Recieved {0} byte(s) from {1}", nRead, where);
}
===========