https://github.com/jchristn/simpleudp
SimpleUdp is a super simple way of building UDP clients and servers in C#.
https://github.com/jchristn/simpleudp
c-sharp csharp dotnet message nuget tcp udp udp-client udp-protocol udp-server udp-socket
Last synced: 4 months ago
JSON representation
SimpleUdp is a super simple way of building UDP clients and servers in C#.
- Host: GitHub
- URL: https://github.com/jchristn/simpleudp
- Owner: jchristn
- License: mit
- Created: 2020-07-23T03:00:16.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T21:34:35.000Z (about 1 year ago)
- Last Synced: 2024-12-12T22:08:40.570Z (5 months ago)
- Topics: c-sharp, csharp, dotnet, message, nuget, tcp, udp, udp-client, udp-protocol, udp-server, udp-socket
- Language: C#
- Homepage:
- Size: 762 KB
- Stars: 43
- Watchers: 3
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

# SimpleUdp
## Simple wrapper for UDP client and server in C#
[](https://www.nuget.org/packages/SimpleUdp/) [](https://www.nuget.org/packages/SimpleUdp)
SimpleUdp provides simple methods for creating your own UDP-based sockets application, enabling easy integration of sending data, receiving data, and building state machines.
## New in v2.0.x- Retarget to .NET 8.0
- Removal of `Start`, `Stop` APIs, and, the started event
- Better multi-platform compatibility (Windows, Mac OSX, Ubuntu)## Help or Feedback
Need help or have feedback? Please file an issue here!
## Special Thanks
Thanks to community members that have helped improve this library! @jholzer @charleypeng @seatrix
## Need TCP Instead?
I have you covered.
- WatsonTcp - easiest way to build TCP-based applications with built-in framing
- Github: https://github.com/jchristn/watsontcp
- NuGet: https://www.nuget.org/packages/WatsonTcp/
- [](https://www.nuget.org/packages/WatsonTcp/)
- SimpleTcp - lightweight TCP wrapper without framing
- Github: https://github.com/jchristn/simpletcp
- NuGet: https://www.nuget.org/packages/SuperSimpleTcp/
- [](https://www.nuget.org/packages/SuperSimpleTcp/)
- CavemanTcp - TCP wrapper exposing controls for sending and receiving data to build state machines
- Github: https://github.com/jchristn/cavemantcp
- NuGet: https://www.nuget.org/packages/CavemanTcp/
- [](https://www.nuget.org/packages/CavemanTcp/)
Don't know what to use? Just ask! File an issue, I'll be happy to help.## Simple Example
Start a node.
```
using SimpleUdp;UdpEndpoint udp = new UdpEndpoint("127.0.0.1", 8000);
udp.EndpointDetected += EndpointDetected;// only if you want to receive messages...
udp.DatagramReceived += DatagramReceived;// send a message...
udp.Send("127.0.0.1", 8001, "Hello to my friend listening on port 8001!");static void EndpointDetected(object sender, EndpointMetadata md)
{
Console.WriteLine("Endpoint detected: " + md.Ip + ":" + md.Port);
}static void DatagramReceived(object sender, Datagram dg)
{
Console.WriteLine("[" + dg.Ip + ":" + dg.Port + "]: " + Encoding.UTF8.GetString(dg.Data));
}
```## The Node Project
Start node 1.
```
Node\bin\Debug\netcoreapp3.1> node 127.0.0.1 8000
```Start node 2.
```
Node\bin\Debug\netcoreapp3.1> node 127.0.0.1 8001
```Send message from node 1 to node 2. To do this, enter a command as follows:
```
[ip:port] [msg]
```
i.e.
```
127.0.0.1:8001 hello to my friend running on port 8001!
``````
[127.0.0.1:8000 Command/? for help]: 127.0.0.1:8001 hello to my friend on port 8001!
```Send message from node 2 to node 1.
```
[127.0.0.1:8001 Command/? for help]: Endpoint detected: 127.0.0.1:8000
[127.0.0.1:8000]: hello to my friend on port 8001!
127.0.0.1:8000 hello back to you my friend!
```
## Version HistoryPlease refer to CHANGELOG.md.