[RDY] fix TCP connection (issue #870)

This fixes the broken TCP connection. It does not change the functions used to copy the IP address. Maybe there are some more improvements to be made here as described in issue #870.
There are a number of `long ints` that would map into the range of `0..0xffff` after a cast to `int`. We could have different representations for the same address,
```
127.0.0.1:1024
127.0.0.1:4294968320
```
and trying to listen on the same port twice will probably fail.