The code must be in "Listen" state for others to connect to it.
Use the "netstat" command and look for ports "listening".
I wonder if "bind()" (https://linux.die.net/man/2/bind) can be used to check if a service is "listening".
The states allowed is restricted, the client must hit a server with an Internet service "listening". Otherwise it is not available or "busy". The Windows sockets "linger" - are half-made and can be used from the zoombie "WAIT" state. See https://linux.die.net/man/2/socket
This is all, you can use regular file "read()" and "write()" and "close()" now. "lenght" is the buffer size of the application, outvalue is number of bytes in the packet, so "len=read(sd,buff,len);" is all and 0 means that something has happened like a disconnect, and "errno" holds the code.
These "services" are no announced anywhere.
Connections in all "Wait" states can be removed.