// constructor #1 (Detects the IP address of the local host) public StationServer(GPSReceiver gpsreceiver, int port) { TCPIPPort = port; GpsReceiver = gpsreceiver; // retrieve the IP address automatically string hostName = Dns.GetHostName(); IPAddress[] hostIPAddresses = Dns.GetHostAddresses(hostName); Boolean found = false; int i = 0; while (!found) { IpAd = hostIPAddresses[i]; if (IpAd.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { found = true; } else { i++; } } }
// client connection constructor #2 public ClientConnectionThread(Socket sock) { // let the thread be inactive for the moment... Active = false; ClientSocket = sock; SocketBuffer = new RollingBuffer(); Commands = new CommandQueue(); GpsReceiver = null; }