Lines Matching refs:fd

56 #define read(fd, buf, len)        recv(fd, (char *) (buf), (int) (len), 0)
57 #define write(fd, buf, len) send(fd, (char *) (buf), (int) (len), 0)
58 #define close(fd) closesocket(fd)
130 static int check_fd(int fd, int for_select)
132 if (fd < 0) {
144 if (for_select && fd >= FD_SETSIZE) {
157 ctx->fd = -1;
190 ctx->fd = (int) socket(AF_INET, SOCK_STREAM, 0);
192 ctx->fd = (int) socket(cur->ai_family, cur->ai_socktype,
195 if(ctx->fd < 0)
201 if (connect(ctx->fd, cur->ai_addr, MSVC_INT_CAST cur->ai_addrlen) == 0) {
207 lwip_close(ctx->fd);
209 close(ctx->fd);
247 ctx->fd = (int) socket(cur->ai_family, cur->ai_socktype,
249 if (ctx->fd < 0) {
255 if (setsockopt(ctx->fd, SOL_SOCKET, SO_REUSEADDR,
258 lwip_close(ctx->fd);
260 close(ctx->fd);
266 if (bind(ctx->fd, cur->ai_addr, MSVC_INT_CAST cur->ai_addrlen) != 0) {
268 lwip_close(ctx->fd);
270 close(ctx->fd);
278 if (listen(ctx->fd, MBEDTLS_NET_LISTEN_BACKLOG) != 0) {
280 lwip_close(ctx->fd);
282 close(ctx->fd);
326 if ((lwip_fcntl(ctx->fd, F_GETFL, 0) & O_NONBLOCK) != O_NONBLOCK) {
328 if ((fcntl(ctx->fd, F_GETFL) & O_NONBLOCK) != O_NONBLOCK) {
370 if (getsockopt(bind_ctx->fd, SOL_SOCKET, SO_TYPE,
378 ret = client_ctx->fd = (int) accept(bind_ctx->fd,
384 ret = (int) recvfrom(bind_ctx->fd, buf, sizeof(buf), MSG_PEEK,
410 if (connect(bind_ctx->fd, (struct sockaddr *) &client_addr, n) != 0) {
414 client_ctx->fd = bind_ctx->fd;
415 bind_ctx->fd = -1; /* In case we exit early */
418 if (getsockname(client_ctx->fd,
420 (bind_ctx->fd = (int) socket(local_addr.ss_family,
422 setsockopt(bind_ctx->fd, SOL_SOCKET, SO_REUSEADDR,
427 if (bind(bind_ctx->fd, (struct sockaddr *) &local_addr, n) != 0) {
465 return ioctlsocket(ctx->fd, FIONBIO, &n);
468 return lwip_fcntl(ctx->fd, F_SETFL, lwip_fcntl(ctx->fd, F_GETFL, 0) & ~O_NONBLOCK);
470 return fcntl(ctx->fd, F_SETFL, fcntl(ctx->fd, F_GETFL) & ~O_NONBLOCK);
480 return ioctlsocket(ctx->fd, FIONBIO, &n);
483 return lwip_fcntl(ctx->fd, F_SETFL, lwip_fcntl(ctx->fd, F_GETFL, 0) | O_NONBLOCK);
485 return fcntl(ctx->fd, F_SETFL, fcntl(ctx->fd, F_GETFL) | O_NONBLOCK);
502 int fd = ctx->fd;
504 ret = check_fd(fd, 1);
522 FD_SET((SOCKET) fd, &read_fds);
528 FD_SET((SOCKET) fd, &write_fds);
539 ret = select(fd + 1, &read_fds, &write_fds, NULL,
548 if (FD_ISSET(fd, &read_fds)) {
551 if (FD_ISSET(fd, &write_fds)) {
584 int fd = ((mbedtls_net_context *) ctx)->fd;
586 ret = check_fd(fd, 0);
591 ret = (int) recv( fd, buf, len, 0);
594 ret = (int) read(fd, buf, len);
632 int fd = ((mbedtls_net_context *) ctx)->fd;
634 ret = check_fd(fd, 1);
640 FD_SET((SOCKET) fd, &read_fds);
645 ret = select(fd + 1, &read_fds, NULL, NULL, timeout == 0 ? NULL : &tv);
677 int fd = ((mbedtls_net_context *) ctx)->fd;
679 ret = check_fd(fd, 0);
685 ret = (int) send(fd, buf, len, 0);
688 ret = (int) write(fd, buf, len);
722 if (ctx->fd == -1) {
726 lwip_close(ctx->fd);
728 close(ctx->fd);
731 ctx->fd = -1;
739 if (ctx->fd == -1) {
743 lwip_shutdown(ctx->fd, 2);
744 lwip_close(ctx->fd);
746 shutdown(ctx->fd, 2);
747 close(ctx->fd);
750 ctx->fd = -1;