TCP mode: MTR terminated with signal SIGPIPE

Looks like the same issue at the bottom of this report:
https://github.com/traviscross/mtr/issues/28

 % uname -a; ./mtr -rT localhost; echo $?
 Start: Thu Jun 12 17:09:11 2014
 SunOS opensolaris 5.11 oi_151a9 i86pc i386 i86pc
 141

 % uname -srm; ./mtr -4rT localhost; echo $?
 NetBSD 6.1.3_PATCH i386
 Start: Thu Jun 12 16:14:47 2014
 141

 % gdb ./mtr
 (gdb) set args -4rT localhost
 (gdb) r
 Start: Thu Jun 12 16:15:36 2014
 Program received signal SIGPIPE, Broken pipe.
 [Switching to LWP 1]
 0xbb767387 in write () from /usr/lib/libc.so.12

 (gdb) bt
 #0  0xbb767387 in write () from /usr/lib/libc.so.12
 #1  0xbb470263 in write () from /usr/lib/libpthread.so.1
 #2  0x0804fea6 in net_process_fds (writefd=0xbfbfeaac) at net.c:1542
 #3  0x080544a7 in select_loop () at select.c:264
 #4  0x0804d5ee in main (argc=3, argv=0xbfbfec58) at mtr.c:719

 (gdb) list net.c:1541,1543
 1541        if (fd > 0 && FD_ISSET(fd, writefd)) {
 1542          r = write(fd, "G", 1);
 1543          /* if write was successful, or connection refused we have
 (gdb)

fix:
 If the socket is connected, getpeername() will return 0.
 Else getpeername() will return ENOTCONN, and read(,,1) will produce the right errno.
 This is a combination of suggestions from Douglas C. Schmidt and Ken Keys.