To create a socket in C#, you can use the System.Net.Sockets namespace. The following code demonstrates how to create a TCP socket in C#:
main.cs954 chars38 lines
The code creates a TCP socket that listens on port 5000. When a client connects, it accepts the connection and handles it in the while loop.
Similarly, you can create a UDP socket using the same namespace and classes as with TCP. Just replace ProtocolType.Tcp
with ProtocolType.Udp
when creating the socket.
gistlibby LogSnag