Skip to content
Snippets Groups Projects
Commit 383908c3 authored by Cyril HECKMANN's avatar Cyril HECKMANN
Browse files

Instanciation une seule fois des buffers

parent b1468f94
No related merge requests found
......@@ -10,6 +10,22 @@ namespace ClientUdp
{
class ClientUdp
{
static void readNet(Socket client,EndPoint server)
{
byte[] buffer = new byte[1500];
while (true)
{
int nBytes = client.ReceiveFrom(buffer, buffer.Length, SocketFlags.None, ref server);
ChatMessage receive = new ChatMessage(buffer);
Console.WriteLine("Nouveau message de "
+ server
+ " (" + nBytes + " octets)"
+ ": \"" + receive.data + "\"");
}
}
static void Main(string[] args)
{
......
......@@ -52,13 +52,13 @@ namespace ServeurUdp
//************************************************************** Communications
byte[] buffer = new byte[1500];
while (listen)
{
Console.WriteLine('\n' + "Attente d'une nouveau message...");
// Reception message client
EndPoint lastUser = new IPEndPoint(IPAddress.Any, 0);
byte[] buffer = new byte[1500];
int nBytes = serverSocket.ReceiveFrom(buffer, buffer.Length, SocketFlags.None, ref lastUser);
ChatMessage receive = new ChatMessage(buffer);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment