[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.
Creating a third commit would possibly be cleaner. If you add it to the second commit, please detail it like this:

```
- description of bug + fix #1
- description of bug + fix #2
...
```

Thanks!