Lines Matching refs:sock
156 static void set_sock_priority(int sock) { in set_sock_priority() argument
162 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&val, sizeof(val)); in set_sock_priority()
168 setsockopt(sock, IPPROTO_IP, IP_TOS, (void*)&val, sizeof(val)); in set_sock_priority()
175 setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &val, sizeof(val)); in set_sock_priority()
194 int sock; in dropbear_listen() local
241 sock = socks[nsock]; /* For clarity */ in dropbear_listen()
243 if (sock < 0) { in dropbear_listen()
252 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &val, sizeof(val)); in dropbear_listen()
255 setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&linger, sizeof(linger)); in dropbear_listen()
257 set_sock_priority(sock); in dropbear_listen()
259 if (bind(sock, res->ai_addr, res->ai_addrlen) < 0) { in dropbear_listen()
261 close(sock); in dropbear_listen()
266 if (listen(sock, 20) < 0) { in dropbear_listen()
268 close(sock); in dropbear_listen()
273 *maxfd = MAX(*maxfd, sock); in dropbear_listen()
307 int sock; in connect_remote() local
332 sock = -1; in connect_remote()
336 sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); in connect_remote()
337 if (sock < 0) { in connect_remote()
343 if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { in connect_remote()
344 close(sock); in connect_remote()
345 sock = -1; in connect_remote()
354 if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) { in connect_remote()
360 close(sock); in connect_remote()
361 sock = -1; in connect_remote()
369 if (sock < 0 && !(errno == EINPROGRESS && nonblocking)) { in connect_remote()
380 set_sock_priority(sock); in connect_remote()
384 if (sock > 0 && errstring != NULL && *errstring != NULL) { in connect_remote()
388 TRACE(("leave connect_remote: sock %d\n", sock)) in connect_remote()
389 return sock; in connect_remote()