uwe.kl

uwe.kl

  • 0
  • 3
  • 0

Binding Socket seems to be static after compile.

Jul 28 2004 1:26 AM
Hi! I'm using the System.Net.Sockets.Socket Class to set up a server to listen for incoming connections. For the IpEndPoint I used "IPAddress.Any" as in example 1 below. Everything works fine till I move to some other machine. The exmaple seems to run only on the machine that it was compiled on. If I change the IPAddress to "IPAddress.Parse("...")" and put in the correct IPAddress of the computer, the same code is working on all computers. So, where is my mistake? Or is there a way to read the IPAddress of the machine I am running the program on? I think it is a very bad solution to configure the Systems-IP always before i will run the program. //example 1 //Is not working, only on the system it was compiled on. ... IPEndPoint ipep = new IPEndPoint(IPAddress.Any,11000); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); sock.Bind(ipep); sock.Listen(100); ... //Example 2 //Is working ... IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.1.44"),11000); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); sock.Bind(ipep); sock.Listen(100); ... Thanks in advance, Snowprog.