Skip to content

Instantly share code, notes, and snippets.

@rdeioris
Created February 7, 2020 16:39
Show Gist options
  • Save rdeioris/509180a3c9ffaf123703acc0bc2ab8fb to your computer and use it in GitHub Desktop.
Save rdeioris/509180a3c9ffaf123703acc0bc2ab8fb to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
namespace NetApp001
{
class Program
{
static void Main(string[] args)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint mySelf = new IPEndPoint(IPAddress.Parse("192.168.100.209"), 5000);
socket.Bind(mySelf);
while (true)
{
byte[] data = new byte[4096];
EndPoint sender = new IPEndPoint(0, 0);
int rlen = socket.ReceiveFrom(data, ref sender);
if (rlen > 0)
{
Console.WriteLine(Encoding.ASCII.GetString(data, 0, rlen));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment