[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.
Not sure if this file is in `-Wconversion`, but if so, then if a system has 128-bit longs, it will warn and we'll notice.

Otherwise, if we use `intmax_t`, we'll never have to change the code.

It's a bit stupid we can't just use `long` though...