Network applications use sockets. Sockets is the raw network layer (TCP/UDP). Data is often transmitted using protocols, but sockets let you define your own protocols.
This example uses golang to setup a socket server.
Learn How To Code: Google’s Go (golang) Programming Language
To use sockets, load the net module, with the line
Then the steps are sequentially to listen on a network port, to accept an incoming connections and then to process incoming data in a loop.
The example below opens a socket server on port 8000 of your local computer.
If you name the program
server.go, you can start it with
go run server.go.
You can connect to the server with telnet,
telnet 127.0.0.1 8000 or from another
computer in your local network. Then send any message, the server will receive them.
(make sure your firewall isn’t blocking).
// Very basic socket server