static void Main(string[] args) { string connStr = GetConnStrForThisMashine.GetConnStr(); saveCredentials = new SaveUserCredentials(connStr); IPEndPoint endPoint = new IPEndPoint(ip, port); Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); string data = String.Empty; Socket socket = null; try { listener.Bind(endPoint); listener.Listen(0); while (true) { byte[] myBuffer = new byte[buffSize]; Console.WriteLine("Waiting for connection..."); socket = listener.Accept(); while (true) { int receiveCount = socket.Receive(myBuffer); if (receiveCount != 0) { break; } } //// UserDTO userDTO = (UserDTO)DTOSerializerHelper.DTOSerializerHelper.DesirealizeDTO(myBuffer); //have data -> send to DB //// saveCredentials.SaveUserCredentials(userDTO); } } //catch (Exception ex) //{ // //Console.WriteLine($"Exception: {ex}"); //} finally { socket.Shutdown(SocketShutdown.Receive); if (socket != null) { socket.Close(); } } }
public Service() { connStr = GetConnStrForThisMashine.GetConnStr(); try { userValidate = /*null;//*/ new ValidateUser(connStr); if (userValidate == null) { throw new Exception("out of memory"); } createHouse = new CreateHouse(connStr); saveUser = new SaveUserCredentials(connStr); methodsWork = new WorkMethods(connStr); } catch (OutOfMemoryException ex) { throw new Exception("out of memory" + ex.InnerException.ToString()); } }