Shell script would be fine for a connect-work-disconnect method of working.
But it is grossly ineffective for maintaining a long-running P2P network node, where long-lasting TCP connections are preferred.
One could work around that inefficiency in at least a couple of ways:
1) Background a task that has a file descriptor open back to the active shell, that can manipulate and communicate with sockets, or
2) Use a shell that provides this builtin, such as the net/socket module in zsh as described at
http://www.cims.nyu.edu/cgi-systems/info2html?%28zsh%29The%2520zsh%2Fnet%2Fsocket%2520Module