summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-29 21:21:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-29 21:21:06 -0700
commit9557a79765457c2cd1a7214f0d8d51d2ea62ed70 (patch)
treef01f0ef6ffe860d2ccabb053d937b24e058ebc04 /socket.c
parent7006ede97348c57aff89d6af7d19bb6411d9b3f6 (diff)
downloadtxr-9557a79765457c2cd1a7214f0d8d51d2ea62ed70.tar.gz
txr-9557a79765457c2cd1a7214f0d8d51d2ea62ed70.tar.bz2
txr-9557a79765457c2cd1a7214f0d8d51d2ea62ed70.zip
c_num: now takes self argument.
The c_num and c_unum functions now take a self argument for identifying the calling function. This requires changes in a large number of places. In a few places, additional functions acquire a self argument. The ffi module has the most extensive example of this. Some functions mention their name in a larger string, or have scattered literals giving their name; with the introduction of the self local variable, these are replaced by references to self. In the following changelog, the notation TS stands for "take self argument", meaning that the functions acquires a new "val self" argument. The notation DS means "define self": the functions in question defines a self variable, which they pass down. The notation PS means that the functions pass down an existing self variable to functions that now require it. * args.h (args_count): TS. * arith.c (c_unum, c_num): TS. (toint, exptv): DS. * buf.c (buf_check_len, buf_check_alloc_size, buf_check_index, buf_do_set_len, replace_buf, buf_put_buf, buf_put_i8, buf_put_u8, buf_put_char, buf_put_uchar, buf_get_bytes, buf_get_i8, buf_get_u8, buf_get_cptr, buf_strm_get_byte_callback, buf_strm_unget_byte, buf_swap32, str_buf, buf_int, buf_uint, int_buf, uint_buf): PS. (make_duplicate_buf, buf_shrink, sub_buf, buf_print, buf_pprint): DS. * chskum.c (sha256_stream_impl, sha256_buf, crc32_buf, md5_stream_impl, md5_buf): TS. (chksum_ensure_buf, sha256_stream, sha256, sha256_hash, md5_stream, md5, md5_hash): PS. (crc32_stream): DS. * combi.c (perm_while_fun, perm_gen_fun_common, perm_str_gen_fun, rperm_gen_fun, comb_vec_gen_fun, comb_str_gen_fun, rcomb_vec_gen_fun, rcomb_str_gen_fun): DS. * diff.c (dbg_clear, dbg_set, dbg_restore): DS. * eval.c (do_eval, gather_free_refs, maprodv, maprendv, maprodo, do_args_apf, do_args_ipf): DS. (op_dwim, me_op, map_common): PS. (prod_common): TS. * ffi.c (struct txr_ffi_type): release member TS. (make_ffi_type_pointer): PS and release argument TS. (ffi_varray_dynsize, ffi_array_in, ffi_array_put_common, ffi_array_get_common, ffi_varray_in, ffi_varray_null_term): PS. (ffi_simple_release, ffi_ptr_in_release, ffi_struct_release, ffi_wchar_array_get, ffi_array_release_common, ffi_array_release, ffi_varray_release): TS. (ffi_float_put, double_put, ffi_be_i16_put, ffi_be_u16_put, ffi_le_i16_put, ffi_le_u16_put, ffi_be_i32_put, ffi_be_u32_put, ffi_le_i32_put, ffi_sbit_put, ffi_ubit_put, ffi_buf_d_put, make_ffi_type_array, make_ffi_type_enum, ffi_type_compile, make_ffi_type_desc, ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch_save, ffi_put_into, ffi_in, ffi_get, ffi_put, carray_set_length, carray_blank, carray_buf, carray_buf_sync, carray_cptr, carray_refset, carray_sub, carray_replace, carray_uint, carray_int): PS. (carray_vec, carray_list): DS. * filter.c (url_encode, url_decode, base64_stream_enc_impl): DS. * ftw.c (ftw_callback, ftw_wrap): DS. * gc.c (mark_obj, gc_set_delta): DS. * glob.c (glob_wrap): DS. * hash.c (equal_hash, eql_hash, eq_hash, do_make_hash, hash_equal, set_hash_traversal_limit, gen_hash_seed): DS. * itypes.c (c_i8, c_u8, c_i16, c_u16, c_i32, c_u32, c_i64, c_u64, c_short, c_ushort, c_int, c_uint, c_long, c_ulong): PS. * lib.c (seq_iter_rewind): TS and becomes internal. (seq_iter_init_with_info, seq_setpos, replace_str, less, replace_vec, diff, isec, obj_print_impl): PS. (nthcdr, equal, mkstring, mkustring, upcase_str, downcase_str, search_str, sub_str, cat_str, scat2, scat3, fmt_join, split_str_keep, split_str_set, trim_str, int_str, chr_int, chr_str, chr_str_set, vector, vecref, vecref_l, list_vec, copy_vec, sub_vec, cat_vec, lazy_str_put, lazy_str_gt, length_str_ge, length_str_lt, length_str_le, cptr_size_hint, cptr_int, out_lazy_str, out_quasi_str, time_string_local_time, time_string_utc, time_fields_local_time, time_fields_utc, time_struct_local, time_struct_utc, make_time, time_meth, time_parse_meth): DS. (init_str, cat_str_init, cat_str_measure, cat_str_append, vscat, time_fields_to_tm, time_struct_to_tm, make_time_impl): TS. * lib.h (seq_iter_rewind): Declaration removed. (c_num, c_unum, init_str): Declarations updated. * match.c (LOG_MISMATCH, LOG_MATCH): PS. (h_skip, h_coll, do_output_line, do_output, v_skip, v_fuzz, v_collect): DS. * parser.c (parser, circ_backpatch, report_security_problem, hist_save, repl, lino_fileno, lino_getch, lineno_getl, lineno_gets, lineno_open): DS. (parser_set_lineno, lisp_parse_impl): PS. * parser.l (YY_INPUT): PS. * rand.c (make_random_state): PS. * regex.c (print_rec): DS. (search_regex): PS. * signal.c (kill_wrap, raise_wrap, get_sig_handler, getitimer_wrap, setitimer_wrap): DS. * socket.c (addrinfo_in, sockaddr_pack, fd_timeout, to_connect, open_sockfd, sock_mark_connected, sock_timeout): TS. (getaddrinfo_wrap, dgram_set_sock_peer, sock_bind, sock_connect, sock_listen, sock_accept, sock_shutdown, sock_send_timeout, sock_recv_timeout, socketpair_wrap): DS. * stream.c (generic_fill_buf, errno_to_string, stdio_truncate, string_out_put_string, open_fileno, open_command, base_name, dir-name): DS. (unget_byte, put_buf, fill_buf, fill_buf_adjust, get_line_as_buf, formatv, put_byte, test_set_indent_mode, test_neq_set_indent_mode, set_indent_mode, set_indent, inc_indent, set_max_length, set_max_depth, open_subprocess, run ): PS. (fds_subst, fds_swizzle): TS. * struct.c (make_struct_type, super, umethod_args_fun): PS. (method_args_fun): DS. * strudel.c (strudel_put_buf, strudel_fill_buf): DS. * sysif.c (errno_wrap, exit_wrap, usleep_wrap, mkdir_wrap, ensure_dir, makedev_wrap, minor_wrap, major_wrap, mknod_wrap, mkfifo_wrap, wait_wrap, wifexited, wexitstatus, wifsignaled, wtermsig, wcoredump, wifstopped, wstopsig, wifcontinued, dup_wrap, close_wrap, exit_star_wrap, umask_wrap, setuid_wrap, seteuid_wrap, setgid_wrap, setegid_wrap, simulate_setuid_setgid, getpwuid_wrap, fnmatch_wrap, dlopen_wrap): DS. (chmod_wrap, do_chown, flock_pack, do_utimes, poll_wrap, setgroups_wrap, setresuid_wrap, setresgid_wrap, getgrgid_wrap): PS. (c_time): TS. * sysif.h (c_time): Declaration updated. * syslog.c (openlog_wrap, syslog_wrap): DS. * termios.c (termios_pack): TS. (tcgetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_rap, encode_speeds, decode_speeds): DS. * txr.c (compato, array_dim, gc_delta): DS. * unwind.c (uw_find_frames_by_mask): DS. * vm.c (vm_make_desc): PS. (vm_make_closure, vm_swtch): DS.
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c131
1 files changed, 72 insertions, 59 deletions
diff --git a/socket.c b/socket.c
index f0c252bf..38cbd7f0 100644
--- a/socket.c
+++ b/socket.c
@@ -163,16 +163,17 @@ static val sockaddr_unpack(int family, struct sockaddr_storage *src)
#if HAVE_GETADDRINFO
-static void addrinfo_in(struct addrinfo *dest, val src)
+static void addrinfo_in(struct addrinfo *dest, val src, val self)
{
- dest->ai_flags = c_num(default_arg(slot(src, flags_s), zero));
- dest->ai_family = c_num(default_arg(slot(src, family_s), zero));
- dest->ai_socktype = c_num(default_arg(slot(src, socktype_s), zero));
- dest->ai_protocol = c_num(default_arg(slot(src, protocol_s), zero));
+ dest->ai_flags = c_num(default_arg(slot(src, flags_s), zero), self);
+ dest->ai_family = c_num(default_arg(slot(src, family_s), zero), self);
+ dest->ai_socktype = c_num(default_arg(slot(src, socktype_s), zero), self);
+ dest->ai_protocol = c_num(default_arg(slot(src, protocol_s), zero), self);
}
static val getaddrinfo_wrap(val node_in, val service_in, val hints_in)
{
+ val self = lit("getaddrinfo");
val node = default_arg(node_in, nil);
val service = default_arg(service_in, nil);
val hints = default_arg(hints_in, nil);
@@ -188,7 +189,7 @@ static val getaddrinfo_wrap(val node_in, val service_in, val hints_in)
if (hints) {
memset(&hints_ai, 0, sizeof hints_ai);
- addrinfo_in(&hints_ai, hints);
+ addrinfo_in(&hints_ai, hints, self);
}
res = getaddrinfo(node_u8, service_u8, phints, &alist);
@@ -209,7 +210,7 @@ static val getaddrinfo_wrap(val node_in, val service_in, val hints_in)
if (node_num_p)
ipv4_addr_from_num(&sa->sin_addr, node);
if (svc_num_p)
- sa->sin_port = htons(c_num(service));
+ sa->sin_port = htons(c_num(service, self));
ptail = list_collect(ptail, sockaddr_in_unpack(sa));
}
break;
@@ -219,7 +220,7 @@ static val getaddrinfo_wrap(val node_in, val service_in, val hints_in)
if (node_num_p)
ipv6_addr_from_num(&sa->sin6_addr, node);
if (svc_num_p)
- sa->sin6_port = ntohs(c_num(service));
+ sa->sin6_port = ntohs(c_num(service, self));
ptail = list_collect(ptail, sockaddr_in6_unpack(sa));
}
break;
@@ -243,7 +244,8 @@ static void addr_mismatch(val addr, val family)
}
static void sockaddr_pack(val sockaddr, val family,
- struct sockaddr_storage *buf, socklen_t *len)
+ struct sockaddr_storage *buf, socklen_t *len,
+ val self)
{
val addr_type = typeof(sockaddr);
@@ -256,7 +258,7 @@ static void sockaddr_pack(val sockaddr, val family,
memset(sa, 0, sizeof *sa);
sa->sin_family = AF_INET;
ipv4_addr_from_num(&sa->sin_addr, addr);
- sa->sin_port = ntohs(c_num(port));
+ sa->sin_port = ntohs(c_num(port, self));
*len = sizeof *sa;
} else if (addr_type == sockaddr_in6_s) {
val addr = slot(sockaddr, addr_s);
@@ -271,7 +273,7 @@ static void sockaddr_pack(val sockaddr, val family,
ipv6_addr_from_num(&sa->sin6_addr, addr);
ipv6_flow_info_from_num(sa, flow);
ipv6_scope_id_from_num(sa, scope);
- sa->sin6_port = ntohs(c_num(port));
+ sa->sin6_port = ntohs(c_num(port, self));
*len = sizeof *sa;
} else if (addr_type == sockaddr_un_s) {
val path = slot(sockaddr, path_s);
@@ -642,8 +644,9 @@ static val dgram_get_sock_peer(val stream)
static val dgram_set_sock_peer(val stream, val peer)
{
+ val self = lit("set-sock-peer");
struct dgram_stream *d = coerce(struct dgram_stream *, stream->co.handle);
- sockaddr_pack(peer, d->family, &d->peer_addr, &d->pa_len);
+ sockaddr_pack(peer, d->family, &d->peer_addr, &d->pa_len, self);
return set(mkloc(d->peer, stream), peer);
}
@@ -677,10 +680,11 @@ static_def(struct strm_ops dgram_strm_ops =
static val sock_bind(val sock, val sockaddr)
{
+ val self = lit("sock-bind");
val sfd = stream_fd(sock);
if (sfd) {
- int fd = c_num(sfd);
+ int fd = c_num(sfd, self);
val family = sock_family(sock);
struct sockaddr_storage sa;
socklen_t salen;
@@ -688,7 +692,7 @@ static val sock_bind(val sock, val sockaddr)
(void) setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
- sockaddr_pack(sockaddr, family, &sa, &salen);
+ sockaddr_pack(sockaddr, family, &sa, &salen, self);
if (bind(fd, coerce(struct sockaddr *, &sa), salen) != 0)
uw_throwf(socket_error_s, lit("sock-bind failed: ~d/~s"),
@@ -703,9 +707,9 @@ static val sock_bind(val sock, val sockaddr)
#if HAVE_POLL
-static int fd_timeout(int fd, val timeout, int write)
+static int fd_timeout(int fd, val timeout, int write, val self)
{
- cnum ms = c_num(timeout) / 1000;
+ cnum ms = c_num(timeout, self) / 1000;
int pollms = (ms > INT_MAX) ? INT_MAX : ms;
struct pollfd pfd;
int res;
@@ -728,9 +732,9 @@ static int fd_timeout(int fd, val timeout, int write)
#elif HAVE_SELECT
-static int fd_timeout(int fd, val timeout, int write)
+static int fd_timeout(int fd, val timeout, int write, val self)
{
- cnum us = c_num(timeout);
+ cnum us = c_num(timeout, self);
struct timeval tv;
fd_set fds;
@@ -756,7 +760,7 @@ static int fd_timeout(int fd, val timeout, int write)
#endif
static int to_connect(int fd, struct sockaddr *addr, socklen_t len,
- val sock, val sockaddr, val timeout)
+ val sock, val sockaddr, val timeout, val self)
{
int res;
@@ -780,7 +784,7 @@ static int to_connect(int fd, struct sockaddr *addr, socklen_t len,
break;
}
- res = fd_timeout(fd, timeout, 1);
+ res = fd_timeout(fd, timeout, 1, self);
switch (res) {
case -1:
@@ -805,19 +809,19 @@ static int to_connect(int fd, struct sockaddr *addr, socklen_t len,
return res;
}
-static val open_sockfd(val fd, val family, val type, val mode_str)
+static val open_sockfd(val fd, val family, val type, val mode_str, val self)
{
struct stdio_mode m, m_rpb = stdio_mode_init_rpb;
if (type == num_fast(SOCK_DGRAM)) {
- return make_dgram_sock_stream(c_num(fd), family, nil, 0, 0, 0, 0,
+ return make_dgram_sock_stream(c_num(fd, self), family, nil, 0, 0, 0, 0,
parse_mode(mode_str, m_rpb), 0);
} else {
- FILE *f = (errno = 0, w_fdopen(c_num(fd), c_str(normalize_mode(&m, mode_str, m_rpb))));
+ FILE *f = (errno = 0, w_fdopen(c_num(fd, self), c_str(normalize_mode(&m, mode_str, m_rpb))));
if (!f) {
int eno = errno;
- close(c_num(fd));
+ close(c_num(fd, self));
uw_throwf(errno_to_file_error(eno), lit("error creating stream for socket ~a: ~d/~s"),
fd, num(eno), errno_to_str(eno), nao);
}
@@ -829,6 +833,7 @@ static val open_sockfd(val fd, val family, val type, val mode_str)
static val sock_connect(val sock, val sockaddr, val timeout)
{
+ val self = lit("sock-connect");
val sfd = stream_fd(sock);
if (sfd) {
@@ -836,12 +841,12 @@ static val sock_connect(val sock, val sockaddr, val timeout)
struct sockaddr_storage sa;
socklen_t salen;
- sockaddr_pack(sockaddr, family, &sa, &salen);
+ sockaddr_pack(sockaddr, family, &sa, &salen, self);
- if (to_connect(c_num(sfd), coerce(struct sockaddr *, &sa), salen,
- sock, sockaddr, default_null_arg(timeout)) != 0)
- uw_throwf(socket_error_s, lit("sock-connect ~s to addr ~s: ~d/~s"),
- sock, sockaddr, num(errno), errno_to_str(errno), nao);
+ if (to_connect(c_num(sfd, self), coerce(struct sockaddr *, &sa), salen,
+ sock, sockaddr, default_null_arg(timeout), self) != 0)
+ uw_throwf(socket_error_s, lit("~a: ~s to addr ~s: ~d/~s"),
+ self, sock, sockaddr, num(errno), errno_to_str(errno), nao);
sock_set_peer(sock, sockaddr);
@@ -853,10 +858,10 @@ static val sock_connect(val sock, val sockaddr, val timeout)
return sock;
}
- uw_throwf(socket_error_s, lit("sock-connect: cannot connect ~s"), sock, nao);
+ uw_throwf(socket_error_s, lit("~a: cannot connect ~s"), self, sock, nao);
}
-static val sock_mark_connected(val sock)
+static val sock_mark_connected(val sock, val self)
{
val sfd = stream_fd(sock);
@@ -865,9 +870,9 @@ static val sock_mark_connected(val sock)
struct sockaddr_storage sa = all_zero_init;
socklen_t salen = sizeof sa;
- (void) getpeername(c_num(sfd), coerce(struct sockaddr *, &sa), &salen);
+ (void) getpeername(c_num(sfd, self), coerce(struct sockaddr *, &sa), &salen);
- sock_set_peer(sock, sockaddr_unpack(c_num(family), &sa));
+ sock_set_peer(sock, sockaddr_unpack(c_num(family, self), &sa));
if (sock_type(sock) == num_fast(SOCK_DGRAM)) {
struct dgram_stream *d = coerce(struct dgram_stream *, sock->co.handle);
@@ -882,11 +887,12 @@ static val sock_mark_connected(val sock)
static val sock_listen(val sock, val backlog)
{
+ val self = lit("sock-listen");
val sfd = stream_fd(sock);
if (!sfd)
- uw_throwf(socket_error_s, lit("sock-listen: cannot listen on ~s"),
- sock, nao);
+ uw_throwf(socket_error_s, lit("~a: cannot listen on ~s"),
+ self, sock, nao);
if (sock_type(sock) == num_fast(SOCK_DGRAM)) {
if (sock_peer(sock)) {
@@ -894,20 +900,21 @@ static val sock_listen(val sock, val backlog)
goto failed;
}
} else {
- if (listen(c_num(sfd), c_num(default_arg(backlog, num_fast(16)))))
+ if (listen(c_num(sfd, self), c_num(default_arg(backlog, num_fast(16)), self)))
goto failed;
}
return t;
failed:
- uw_throwf(socket_error_s, lit("sock-listen failed: ~d/~s"),
- num(errno), errno_to_str(errno), nao);
+ uw_throwf(socket_error_s, lit("~a: failed: ~d/~s"),
+ self, num(errno), errno_to_str(errno), nao);
}
static val sock_accept(val sock, val mode_str, val timeout_in)
{
+ val self = lit("sock-accept");
val sfd = stream_fd(sock);
- int fd = sfd ? c_num(sfd) : -1;
+ int fd = sfd ? c_num(sfd, self) : -1;
val family = sock_family(sock);
val type = sock_type(sock);
struct sockaddr_storage sa;
@@ -920,13 +927,13 @@ static val sock_accept(val sock, val mode_str, val timeout_in)
#if HAVE_POLL || HAVE_SELECT
if (timeout) {
- int res = fd_timeout(fd, timeout, 0);
+ int res = fd_timeout(fd, timeout, 0, self);
switch (res) {
case -1:
goto badfd;
case 0:
- uw_throwf(timeout_error_s, lit("sock-accept ~s: timeout"), sock, nao);
+ uw_throwf(timeout_error_s, lit("~a: ~s: timeout"), self, sock, nao);
default:
break;
}
@@ -966,7 +973,7 @@ static val sock_accept(val sock, val mode_str, val timeout_in)
if (nbytes == -1)
goto failed;
- if (nilp(peer = sockaddr_unpack(c_num(family), &sa))) {
+ if (nilp(peer = sockaddr_unpack(c_num(family, self), &sa))) {
free(dgram);
uw_throwf(socket_error_s, lit("sock-accept: ~s isn't a supported socket family"),
family, nao);
@@ -1000,12 +1007,13 @@ static val sock_accept(val sock, val mode_str, val timeout_in)
if (afd < 0)
goto failed;
- if (nilp(peer = sockaddr_unpack(c_num(family), &sa)))
+ if (nilp(peer = sockaddr_unpack(c_num(family, self), &sa)))
uw_throwf(socket_error_s, lit("accept: ~s isn't a supported socket family"),
family, nao);
{
- val stream = open_sockfd(num(afd), family, num_fast(SOCK_STREAM), mode_str);
+ val stream = open_sockfd(num(afd), family, num_fast(SOCK_STREAM),
+ mode_str, self);
sock_set_peer(stream, peer);
return stream;
}
@@ -1020,22 +1028,23 @@ badfd:
static val sock_shutdown(val sock, val how)
{
+ val self = lit("sock-shutdown");
val sfd = stream_fd(sock);
flush_stream(sock);
- if (shutdown(c_num(sfd), c_num(default_arg(how, num_fast(SHUT_WR)))))
- uw_throwf(socket_error_s, lit("shutdown failed: ~d/~s"),
- num(errno), errno_to_str(errno), nao);
+ if (shutdown(c_num(sfd, self), c_num(default_arg(how, num_fast(SHUT_WR)), self)))
+ uw_throwf(socket_error_s, lit("~a failed: ~d/~s"),
+ self, num(errno), errno_to_str(errno), nao);
return t;
}
#if defined SO_SNDTIMEO && defined SO_RCVTIMEO
-static val sock_timeout(val sock, val usec, val name, int which)
+static val sock_timeout(val sock, val usec, val name, int which, val self)
{
- cnum fd = c_num(stream_fd(sock));
- cnum u = c_num(usec);
+ cnum fd = c_num(stream_fd(sock), self);
+ cnum u = c_num(usec, self);
struct timeval tv;
tv.tv_sec = u / 1000000;
@@ -1051,25 +1060,29 @@ static val sock_timeout(val sock, val usec, val name, int which)
static val sock_send_timeout(val sock, val usec)
{
- return sock_timeout(sock, usec, lit("sock-send-timeout"), SO_SNDTIMEO);
+ val self = lit("sock-send-timeout");
+ return sock_timeout(sock, usec, self, SO_SNDTIMEO, self);
}
static val sock_recv_timeout(val sock, val usec)
{
- return sock_timeout(sock, usec, lit("sock-recv-timeout"), SO_RCVTIMEO);
+ val self = lit("sock-recv-timeout");
+ return sock_timeout(sock, usec, self, SO_RCVTIMEO, self);
}
#endif
static val open_socket(val family, val type, val mode_str)
{
- int fd = socket(c_num(family), c_num(type), 0);
- return open_sockfd(num(fd), family, type, mode_str);
+ val self = lit("open-socket");
+ int fd = socket(c_num(family, self), c_num(type, self), 0);
+ return open_sockfd(num(fd), family, type, mode_str, self);
}
static val socketpair_wrap(val family, val type, val mode_str)
{
+ val self = lit("open-socket-pair");
int sv[2] = { -1, -1 };
- int res = socketpair(c_num(family), c_num(type), 0, sv);
+ int res = socketpair(c_num(family, self), c_num(type, self), 0, sv);
val out = nil;
uw_simple_catch_begin;
@@ -1079,11 +1092,11 @@ static val socketpair_wrap(val family, val type, val mode_str)
num(errno), errno_to_str(errno), nao);
{
- val s0 = open_sockfd(num(sv[0]), family, type, mode_str);
- val s1 = open_sockfd(num(sv[1]), family, type, mode_str);
+ val s0 = open_sockfd(num(sv[0]), family, type, mode_str, self);
+ val s1 = open_sockfd(num(sv[1]), family, type, mode_str, self);
- sock_mark_connected(s0);
- sock_mark_connected(s1);
+ sock_mark_connected(s0, self);
+ sock_mark_connected(s1, self);
out = list(s0, s1, nao);
}