summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-02-27 18:40:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-02-27 18:40:58 -0800
commit6f4ce69fc86b9272472ae356f8fa98eca7833c88 (patch)
tree8113264695747f920a352d2416ad2452410f2627 /socket.c
parentf589076e26aa831e3e7effed243860debd6f7f6a (diff)
downloadtxr-6f4ce69fc86b9272472ae356f8fa98eca7833c88.tar.gz
txr-6f4ce69fc86b9272472ae356f8fa98eca7833c88.tar.bz2
txr-6f4ce69fc86b9272472ae356f8fa98eca7833c88.zip
Socket streams know their connected peer address.
* stream.c (struct stdio_handle): New member, peer. (stdio_stream_mark): Mark the new member. (sock_peer, sock_set_peer): New functions. (stream_init): Registered sock-peer intrinsic. * stream.h (sock_peer, sock_set_peer): Declared. * socket.c (sock_connect): If the connect is successful, then store the address into the stream as the peer.
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/socket.c b/socket.c
index b0c90465..c263edb1 100644
--- a/socket.c
+++ b/socket.c
@@ -267,6 +267,8 @@ static val sock_connect(val sock, val sockaddr)
uw_throwf(socket_error_s, lit("connect failed: ~d/~s"),
num(errno), string_utf8(strerror(errno)), nao);
+ sock_set_peer(sock, sockaddr);
+
return t;
}