Share via

UdpClient not found (visual studio 10)

Anisse-yolo 1 Reputation point
2022-03-11T14:14:05.82+00:00

Hello i have to do a project but one of the constraint is that i have to use visualstudio 10 with the program gadgeteer,
i have to creat a server with UdpClient but no matter what i do visual studio keep saying "udpclient not found" what can i do ?

code :

namespace UDPServeur
{
public class Program
{
private static Thread _thEcoute;

    private static void Main(string[] args)
    {
        _thEcoute = new Thread(new ThreadStart(Ecouter));
        _thEcoute.Start();
    }

    private static void Ecouter()
    {
        Console.WriteLine("Préparation à l'écoute...");

        UdpClient serveur = new UdpClient(5035);

        while (true)
        {
            IPEndPoint client = null;
            Console.WriteLine("ÉCOUTE...");

            byte[] data = serveur.Receive(ref client);
            Console.WriteLine("Données reçues en provenance de {0}:{1}.", client.Address, client.Port);

            string message = Encoding.Default.GetString(data);
            Console.WriteLine("CONTENU DU MESSAGE : {0}\n", message);
        }
    }
}

}

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. MotoX80 37,696 Reputation points
    2022-03-14T18:09:04.147+00:00

    Add "using" statements.

    using System.Net;    
    using System.Net.Sockets;   
    

    https://learn.microsoft.com/en-us/dotnet/framework/network-programming/using-udp-services

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.