Untitled

mail@pastecode.io avatar
unknown
plain_text
11 days ago
760 B
2
Indexable
Never
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        UdpClient udpServer = new UdpClient(5000);
        IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);

        Console.WriteLine("Server started.");

        while (true)
        {
            var receivedResults = await udpServer.ReceiveAsync();
            byte[] receivedBytes = receivedResults.Buffer;
            IPEndPoint clientEndPoint = receivedResults.RemoteEndPoint;

            // Echo the audio data back to the client
            await udpServer.SendAsync(receivedBytes, receivedBytes.Length, clientEndPoint);
        }
    }
}
Leave a Comment