fixed closing sockets on both ends and server ->  client errors

Signed-off-by: Miethop <miethpomail@yahoo.co.uk>
added license