Changed some details of the socket port API and started rewriting docs.