Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading.Tasks;
- namespace Server
- {
- class Program
- {
- private static byte[] data;
- static void Main(string[] args)
- {
- data = System.Text.ASCIIEncoding.ASCII.GetBytes("<The packet of data>");
- IPEndPoint ServerEndPoint= new IPEndPoint(IPAddress.Any,9050);
- Socket WinSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- WinSocket.Bind(ServerEndPoint);
- Console.Write("Waiting for client");
- IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
- EndPoint Remote = (EndPoint)(sender);
- int recv = WinSocket.ReceiveFrom(data, ref Remote);
- Console.WriteLine("\nMessage received from {0}:", Remote.ToString());
- Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement