moved common socket operations into static methods in Socket and ServerSocket