public void Close() { int i = skt.Send(Encoding.UTF8.GetBytes(McNetMessages.getLoginMessage())); skt.Close(); Connected = false; }
public void Connect() { int i; Connected = false; string LogInMsg = McNetMessages.getLoginMessage(); if (String.IsNullOrEmpty(ip)) { return; } try { skt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); skt.Connect(ip, port); Connected = true; i = skt.Send(Encoding.UTF8.GetBytes(LogInMsg)); Display("sent login request"); i = skt.Receive(receiveBuffer); string msg = Encoding.UTF8.GetString(receiveBuffer); Display(msg); // \todo check response } catch (Exception ex) { Display(ex.Message); } }