Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- //Creates a UdpClient for reading incoming data.
- UdpClient udpServer = new UdpClient(9999);
- //Creates an IPEndPoint to record the IP Address and port number of the sender.
- //IPAddress ip = IPAddress.Any;
- //udpServer.EnableBroadcast = true;
- IPAddress ip = IPAddress.Parse("192.168.3.64");
- IPEndPoint RemoteIpEndPoint = new IPEndPoint(ip, 9999);
- try
- {
- // Blocks until a message is received on this socket from a remote host (a client).
- /*C*//*onsole.WriteLine("Server is blocked");*/
- int tal = 0;
- while (true)
- {
- //Byte[] receiveBytes = udpServer.Receive(ref RemoteIpEndPoint);
- //Server is now activated");
- //string receivedData = Encoding.ASCII.GetString(receiveBytes);
- //string[] data = receivedData.Split(' ');
- //string clientName = data[0];
- //string text = data[1] + data[2];
- //Console.WriteLine(receivedData);
- ////Console.WriteLine("Received from: " + clientName.ToString() + " " + text.ToString());
- //string sendData = "Server: " + text.ToUpper();
- /*B*//*yte[] sendBytes = Encoding.ASCII.GetBytes(tal);*/
- Byte[] sendBytes = Encoding.ASCII.GetBytes("Number is: " + tal);
- udpServer.Send(sendBytes, sendBytes.Length, RemoteIpEndPoint);
- Console.WriteLine(tal.ToString());
- tal++;
- Thread.Sleep(1000);
- //Console.WriteLine("This message was sent from " +
- // RemoteIpEndPoint.Address.ToString() +
- // " on their port number " +
- // RemoteIpEndPoint.Port.ToString());
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement