Changed method of reading and writing to sockets to be more generic
Transforming socket fds into connection structs