Fixing 2 issues with tcp output

- socket library was not included causnig it to fail
- When running as client a EOFError caused the output to crash.