Problem in Threading
-
Following is my code for a simple thread public static void U() { IPEndPoint ipe = new IPEndPoint(IPAddress.Any,1238); EndPoint LocalEP = (EndPoint) ipe; //Socket ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //ServerSocket.Bind(LocalEP); Console.WriteLine("I am codeproject user"); while(true) { Thread.Sleep(10); Console.Write(". "); } } It is surprised that when I use //Socket ServerSocket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp); the thread is not working .
-
Following is my code for a simple thread public static void U() { IPEndPoint ipe = new IPEndPoint(IPAddress.Any,1238); EndPoint LocalEP = (EndPoint) ipe; //Socket ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //ServerSocket.Bind(LocalEP); Console.WriteLine("I am codeproject user"); while(true) { Thread.Sleep(10); Console.Write(". "); } } It is surprised that when I use //Socket ServerSocket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp); the thread is not working .
Funny... I don't see any code in your post that creates a new thread, so yes, it doesn't work. What are you trying to accomplish? I assume it's a multithreaded server application that accept client connections and launches a new thread for each client. But in your case, you never started a listener, so I fail to see how your even going to accept connections... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome