Lines Matching refs:fd
66 #define read(fd,buf,len) recv(fd,(char*)buf,(int) len,0) argument
67 #define write(fd,buf,len) send(fd,(char*)buf,(int) len,0) argument
68 #define close(fd) closesocket(fd) argument
130 ctx->fd = -1; in mbedtls_net_init()
157 ctx->fd = (int) socket( cur->ai_family, cur->ai_socktype, in mbedtls_net_connect()
159 if( ctx->fd < 0 ) in mbedtls_net_connect()
165 if( connect( ctx->fd, cur->ai_addr, MSVC_INT_CAST cur->ai_addrlen ) == 0 ) in mbedtls_net_connect()
171 close( ctx->fd ); in mbedtls_net_connect()
206 ctx->fd = (int) socket( cur->ai_family, cur->ai_socktype, in mbedtls_net_bind()
208 if( ctx->fd < 0 ) in mbedtls_net_bind()
215 if( setsockopt( ctx->fd, SOL_SOCKET, SO_REUSEADDR, in mbedtls_net_bind()
218 close( ctx->fd ); in mbedtls_net_bind()
223 if( bind( ctx->fd, cur->ai_addr, MSVC_INT_CAST cur->ai_addrlen ) != 0 ) in mbedtls_net_bind()
225 close( ctx->fd ); in mbedtls_net_bind()
233 if( listen( ctx->fd, MBEDTLS_NET_LISTEN_BACKLOG ) != 0 ) in mbedtls_net_bind()
235 close( ctx->fd ); in mbedtls_net_bind()
275 if( ( fcntl( ctx->fd, F_GETFL ) & O_NONBLOCK ) != O_NONBLOCK ) in net_would_block()
314 if( getsockopt( bind_ctx->fd, SOL_SOCKET, SO_TYPE, in mbedtls_net_accept()
324 ret = client_ctx->fd = (int) accept( bind_ctx->fd, in mbedtls_net_accept()
332 ret = (int) recvfrom( bind_ctx->fd, buf, sizeof( buf ), MSG_PEEK, in mbedtls_net_accept()
360 if( connect( bind_ctx->fd, (struct sockaddr *) &client_addr, n ) != 0 ) in mbedtls_net_accept()
363 client_ctx->fd = bind_ctx->fd; in mbedtls_net_accept()
364 bind_ctx->fd = -1; /* In case we exit early */ in mbedtls_net_accept()
367 if( getsockname( client_ctx->fd, in mbedtls_net_accept()
369 ( bind_ctx->fd = (int) socket( local_addr.ss_family, in mbedtls_net_accept()
371 setsockopt( bind_ctx->fd, SOL_SOCKET, SO_REUSEADDR, in mbedtls_net_accept()
377 if( bind( bind_ctx->fd, (struct sockaddr *) &local_addr, n ) != 0 ) in mbedtls_net_accept()
418 return( ioctlsocket( ctx->fd, FIONBIO, &n ) ); in mbedtls_net_set_block()
420 return( fcntl( ctx->fd, F_SETFL, fcntl( ctx->fd, F_GETFL ) & ~O_NONBLOCK ) ); in mbedtls_net_set_block()
429 return( ioctlsocket( ctx->fd, FIONBIO, &n ) ); in mbedtls_net_set_nonblock()
431 return( fcntl( ctx->fd, F_SETFL, fcntl( ctx->fd, F_GETFL ) | O_NONBLOCK ) ); in mbedtls_net_set_nonblock()
461 int fd = ((mbedtls_net_context *) ctx)->fd; in mbedtls_net_recv() local
463 if( fd < 0 ) in mbedtls_net_recv()
466 ret = (int) read( fd, buf, len ); in mbedtls_net_recv()
500 int fd = ((mbedtls_net_context *) ctx)->fd; in mbedtls_net_recv_timeout() local
502 if( fd < 0 ) in mbedtls_net_recv_timeout()
506 FD_SET( fd, &read_fds ); in mbedtls_net_recv_timeout()
511 ret = select( fd + 1, &read_fds, NULL, NULL, timeout == 0 ? NULL : &tv ); in mbedtls_net_recv_timeout()
541 int fd = ((mbedtls_net_context *) ctx)->fd; in mbedtls_net_send() local
543 if( fd < 0 ) in mbedtls_net_send()
546 ret = (int) write( fd, buf, len ); in mbedtls_net_send()
576 if( ctx->fd == -1 ) in mbedtls_net_free()
579 shutdown( ctx->fd, 2 ); in mbedtls_net_free()
580 close( ctx->fd ); in mbedtls_net_free()
582 ctx->fd = -1; in mbedtls_net_free()