Note that there are some explanatory texts on larger screens.

plurals
  1. POUDP Problem With Non-Reception
    text
    copied!<p>I am new to Network Programming, and I am having a problem with some code I've been testing as the basis of a LAN chat program.</p> <p>Server Code:</p> <pre><code>public static void Main() { UdpClient publisher = new UdpClient("230.0.0.1", 8899); UdpClient subscriber = new UdpClient("230.0.0.2", 8800); IPAddress addr = IPAddress.Parse("230.0.0.1"); subscriber.JoinMulticastGroup(addr); Console.WriteLine("Running chat program at 230.0.0.1:8899"); while (true) { IPEndPoint ep = null; byte[] chats = subscriber.Receive(ref ep); string chatstring = Encoding.ASCII.GetString(chats); Console.WriteLine(chatstring); string msg = String.Format(chatstring); byte[] sdata = Encoding.ASCII.GetBytes(msg); publisher.Send(sdata, sdata.Length); System.Threading.Thread.Sleep(500); } } </code></pre> <p>And the client program:</p> <pre><code>static void Main(string[] args) { UdpClient subscriber = new UdpClient("230.0.0.1", 8899); IPAddress addr = IPAddress.Parse("230.0.0.1"); subscriber.JoinMulticastGroup(addr); IPEndPoint ep = null; Thread SendChats = new Thread(Send); SendChats.Start(); while (true) { byte[] receivedbytes = subscriber.Receive(ref ep); string receivedchats = Encoding.ASCII.GetString(receivedbytes); Console.WriteLine(receivedchats); Thread.Sleep(500); } } static void Send() { UdpClient publisher = new UdpClient("230.0.0.2", 8800); while (true) { string msg = Console.ReadLine(); byte[] sdata = Encoding.ASCII.GetBytes(msg); publisher.Send(sdata, sdata.Length); Thread.Sleep(400); } } </code></pre> <p>By my figuring, the server program SHOULD be receiving data from the client, but alas, after a message is typed in and delivered, there is never anything getting through. Am I missing something?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload