added a bunch of socket functions (thanks to marc)