Lines Matching defs:sock
274 int sock;
308 sock = socket (sa->sa_family, SOCK_STREAM, 0);
309 if (sock < 0)
316 int err = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on));
333 setsockopt (sock, SOL_SOCKET, SO_RCVBUF,
348 if (bind (sock, bind_sa, sockaddr_size (bind_sa)) < 0)
354 if (connect_with_timeout (sock, sa, sockaddr_size (sa),
359 assert (sock >= 0);
362 DEBUGP (("Created socket %d.\n", sock));
363 return sock;
370 if (sock >= 0)
371 fd_close (sock);
389 int sock;
406 sock = connect_to_ip (ip, port, host);
407 if (sock >= 0)
412 return sock;
453 int sock;
462 sock = socket (bind_address->family, SOCK_STREAM, 0);
463 if (sock < 0)
467 setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, setopt_ptr, setopt_size);
472 if (bind (sock, sa, sockaddr_size (sa)) < 0)
474 fd_close (sock);
477 DEBUGP (("Local socket fd %d bound.\n", sock));
483 if (getsockname (sock, sa, &addrlen) < 0)
489 fd_close (sock);
496 if (listen (sock, 1) < 0)
498 fd_close (sock);
501 return sock;
517 int sock;
533 sock = accept (local_sock, sa, &addrlen);
534 DEBUGP (("Accepted client at socket %d.\n", sock));
535 return sock;
546 socket_ip_address (int sock, ip_address *ip, int endpoint)
554 ret = getsockname (sock, sockaddr, &addrlen);
556 ret = getpeername (sock, sockaddr, &addrlen);
682 test_socket_open (int sock)
691 FD_SET (sock, &check_set);
697 if (select (sock + 1, &check_set, NULL, NULL, &to) == 0)