private static void Main(string[] args) { TcpListener server = null; try { server = new TcpListener(IPAddress.Any, 9852); server.Start(); Console.WriteLine("Server started."); TcpClient client = server.AcceptTcpClient(); NetworkStream stream = client.GetStream(); Console.WriteLine("Client accepted."); byte[] bytes = new byte[1024]; stream.Read(bytes, 0, bytes.Length); Packet packet = new Packet(new List<byte>(bytes)); LoginRequest request = (LoginRequest)packet.data; Console.WriteLine(request.id); Console.WriteLine(request.pw); stream.Close(); client.Close(); } catch (SocketException e) { Console.WriteLine(e); } server.Stop(); Console.WriteLine("Server Closed."); }
public void OnLoginClicked() { Packet packet = new Packet (new LoginRequest (ID.text, PW.text)); stream.Write(packet.Serialize().ToArray(), 0, packet.serializedSize); }