Lines Matching defs:sock

170 void crCloseSocket( CRSocket sock )
174 if (sock <= 0)
178 SocketDestroyCallback(CR_SOCKET_DESTROY, sock);
182 fail = ( closesocket( sock ) != 0 );
184 shutdown( sock, 2 /* RDWR */ );
185 fail = ( close( sock ) != 0 );
190 crWarning( "crCloseSocket( sock=%d ): %s",
191 sock, crTCPIPErrorString( err ) );
202 __tcpip_read_exact( CRSocket sock, void *buf, unsigned int len )
209 if ( sock <= 0 )
214 const int num_read = recv( sock, dst, (int) len, 0 );
273 __tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len )
281 if ( sock <= 0 )
286 const int num_written = send( sock, src, len, 0 );
323 spankSocket( CRSocket sock )
338 if ( setsockopt( sock, SOL_SOCKET, SO_SNDBUF,
346 if ( setsockopt( sock, SOL_SOCKET, SO_RCVBUF,
355 if ( setsockopt( sock, SOL_SOCKET, SO_REUSEADDR,
363 if ( setsockopt( sock, IPPROTO_TCP, TCP_NODELAY,
392 int i, sock = -1;
412 sock = socket( AF_INET, SOCK_STREAM, 0 );
413 if ( sock == -1 )
418 spankSocket( sock );
424 if ( bind( sock, (struct sockaddr *) &servaddr, sizeof(servaddr) ) )
431 if ( listen( sock, 100 /* max pending connections */ ) )
455 sock = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
456 if ( sock == -1 )
464 spankSocket( sock );
466 if ( bind( sock, cur->ai_addr, cur->ai_addrlen ) )
471 crCloseSocket( sock );
475 if ( listen( sock, 100 /* max pending connections */ ) )
479 crCloseSocket( sock );
495 sockets[count] = sock;
498 return sock;
689 crDebug( "Dead connection (sock=%d, host=%s), removing from pool",
821 const int sock = conn->tcp_socket;
837 (void) recv(sock, &len, sizeof(len), MSG_PEEK);
846 if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 )
886 if ( __tcpip_read_exact( sock, tcpip_buffer + 1, total) <= 0 )
889 total, sock );
914 if ( __tcpip_read_exact( sock, tcpip_buffer + 1 + total, leftover-handled) <= 0 )
998 CRSocket sock = conn->tcp_socket;
1000 if ( (int) sock + 1 > max_fd )
1001 max_fd = (int) sock + 1;
1002 FD_SET( sock, &read_fds );
1024 FD_SET( sock, &only_fd );
1030 if (getpeername(sock, (struct sockaddr *) &s, &slen) < 0) {
1044 FD_CLR(sock, &read_fds);
1045 msock = sock;
1054 if ((int)sock == msock+1)
1055 FD_CLR(sock, &read_fds);
1103 CRSocket sock;
1112 sock = conn->tcp_socket;
1113 if ( !FD_ISSET( sock, &read_fds ) )