added time counter
added error handling for socket
used to spawn child processes