Added some socket stuff, not sure any of this works right.