From f95ed4d31fe7acc1c778c673a9212525c092f970 Mon Sep 17 00:00:00 2001 From: Bruno Da Costa Cunha Date: Mon, 13 Mar 2023 11:41:18 +0100 Subject: [PATCH] =?UTF-8?q?Essay=20de=20faire=20recevoir=20des=20donn?= =?UTF-8?q?=C3=A9es=20du=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/server/ClientConsole/Program.cs | 2 +- code/server/Server/Program.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/server/ClientConsole/Program.cs b/code/server/ClientConsole/Program.cs index 0ab3c95..5e6affe 100644 --- a/code/server/ClientConsole/Program.cs +++ b/code/server/ClientConsole/Program.cs @@ -13,7 +13,7 @@ class Program static void StartClient() { - IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("82.165.19.245"), 3131); + IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3131); UdpClient client = new UdpClient(); // Send connection message to server diff --git a/code/server/Server/Program.cs b/code/server/Server/Program.cs index 3c391f8..4bf003b 100644 --- a/code/server/Server/Program.cs +++ b/code/server/Server/Program.cs @@ -35,7 +35,6 @@ class Program // Assign a unique port to the client IPEndPoint clientEndPoint = new IPEndPoint(IPAddress.Any, nextPort++); ; UdpClient clientSocket = new UdpClient(clientEndPoint); - clientSocket.Client.Bind(clientEndPoint); clients[remoteEndPoint] = clientSocket; // Send connection message to client @@ -46,6 +45,7 @@ class Program // Start thread to receive data from client Thread receiveThread = new Thread(ReceiveMessages); receiveThread.Start(clientSocket); + } } } @@ -58,8 +58,12 @@ class Program while (true) { byte[] receivedData = clientSocket.Receive(ref remoteEndPoint); + Console.WriteLine("PORRA"); string receivedMessage = Encoding.ASCII.GetString(receivedData); + Console.WriteLine("PORRA2"); Console.WriteLine("Received from " + remoteEndPoint.ToString() + ": " + receivedMessage); + Console.WriteLine("PORRA3"); + } } } \ No newline at end of file