D
Daniel Lindberg
Hi, im a beginner in C# and i just cant seem to get my udp broadcasting to
work. What happens is that it just locks down on the Receive call and never
gets any data.
I have the code for the server who answers the broadcast, so i know that it
sends a reply, but i cant figure out why my C# client cant receive it..
Any input on whats wrong with my code will be appreciated
//My code...
byte[] buffer = new byte[50];
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, 0));
socket.Connect(new IPEndPoint(IPAddress.Broadcast, 4242));
socket.Send(System.Text.ASCIIEncoding.ASCII.GetBytes((char)2+"0"+(char)9+"1"
+(char)3));
socket.Receive(buffer, 0, 50, SocketFlags.None);
textBox1.Text = Encoding.ASCII.GetString(buffer);
work. What happens is that it just locks down on the Receive call and never
gets any data.
I have the code for the server who answers the broadcast, so i know that it
sends a reply, but i cant figure out why my C# client cant receive it..
Any input on whats wrong with my code will be appreciated
//My code...
byte[] buffer = new byte[50];
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, 0));
socket.Connect(new IPEndPoint(IPAddress.Broadcast, 4242));
socket.Send(System.Text.ASCIIEncoding.ASCII.GetBytes((char)2+"0"+(char)9+"1"
+(char)3));
socket.Receive(buffer, 0, 50, SocketFlags.None);
textBox1.Text = Encoding.ASCII.GetString(buffer);