// Use this for initialization void Start() { // Initialize CRC Generator crcGenerator = new CRC64(); crcPolynomial = Convert.ToUInt64(crcPolynomialBinary, 2); crcGenerator.Init(crcPolynomial); // Load settings from file FileInfo iniFile = new FileInfo("config.txt"); StreamReader reader = iniFile.OpenText(); string text = reader.ReadLine(); if (text != null) { ipString = text; } text = reader.ReadLine(); if (text != null) { port = int.Parse(text); } // TODO: Connect on prompt rather than application start StartupClient(); }
// Use this for initialization void Start() { crcGenerator = new CRC64(); crcPolynomial = Convert.ToUInt64(crcPolynomialBinary, 2); crcGenerator.Init(crcPolynomial); //byte[] bytes = new byte[1024]; try { // Establish the remote endpoint for the socket. // This example uses port 11000 on the local computer. IPAddress ipAddress = IPAddress.Parse(ipString); remoteEP = new IPEndPoint(ipAddress, 18944); // Create a TCP/IP socket. sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { // Connect the socket to the remote endpoint. Catch any errors. sender.Connect(remoteEP); } catch (ArgumentNullException ane) { Console.WriteLine("ArgumentNullException : {0}", ane.ToString()); } catch (SocketException se) { Console.WriteLine("SocketException : {0}", se.ToString()); } catch (Exception e) { Console.WriteLine("Unexpected exception : {0}", e.ToString()); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }