Lines Matching defs:sock
70 int sock = -1;
93 if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
100 if (setsockopt(sock, SOL_TCP, TCP_NODELAY, &attr, sizeof(attr)) == -1) {
103 close(sock);
104 sock = -1;
108 if (setnonblock(sock, 1) != 0) {
110 close(sock);
111 sock = -1;
115 if (connect(sock, p->ai_addr, p->ai_addrlen) == -1) {
122 FD_SET(sock, &wfds);
124 if ((err = select(sock + 1, NULL, &wfds, NULL, &tv)) == 0) {
128 close(sock);
129 sock = -1;
136 close(sock);
137 sock = -1;
141 if ( ! FD_ISSET(sock, &wfds)) {
145 close(sock);
146 sock = -1;
150 if ((err = getsockopt(sock, SOL_SOCKET, SO_ERROR, &optval, &optlen)) != 0 || optval != 0) {
160 close(sock);
161 sock = -1;
167 close(sock);
168 sock = -1;
186 return(sock);