Lines Matching refs:sockfd

113 ldns_sock_nonblock(int sockfd)
117 if((flag = fcntl(sockfd, F_GETFL)) != -1) {
119 if(fcntl(sockfd, F_SETFL, flag) == -1) {
125 if(ioctlsocket(sockfd, FIONBIO, &on) != 0) {
133 ldns_sock_block(int sockfd)
137 if((flag = fcntl(sockfd, F_GETFL)) != -1) {
139 if(fcntl(sockfd, F_SETFL, flag) == -1) {
145 if(ioctlsocket(sockfd, FIONBIO, &off) != 0) {
153 ldns_sock_wait(int sockfd, struct timeval timeout, int write)
160 FD_SET(FD_SET_T sockfd, &fds);
162 ret = select(sockfd+1, NULL, &fds, NULL, &timeout);
164 ret = select(sockfd+1, &fds, NULL, NULL, &timeout);
171 pfds[0].fd = sockfd;
196 int sockfd;
199 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_STREAM,
204 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == SOCK_INVALID){
205 close_socket(sockfd);
210 ldns_sock_nonblock(sockfd);
211 if (connect(sockfd, (struct sockaddr*)to, tolen) == SOCK_INVALID) {
218 close_socket(sockfd);
224 close_socket(sockfd);
236 if(!ldns_sock_wait(sockfd, timeout, 1)) {
237 close_socket(sockfd);
242 if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)&error,
256 close_socket(sockfd);
267 close_socket(sockfd);
277 ldns_sock_block(sockfd);
279 return sockfd;
303 int sockfd;
305 sockfd = ldns_tcp_connect_from(to, tolen, from, fromlen, timeout);
307 if (sockfd >= 0 && ldns_tcp_send_query(qbin, sockfd, to, tolen) == 0) {
308 close_socket(sockfd);
312 return sockfd;
341 int sockfd;
344 sockfd = ldns_tcp_bgsend_from(qbin, to, tolen, from, fromlen, timeout);
346 if (sockfd == -1) {
350 answer = ldns_tcp_read_wire_timeout(sockfd, answer_size, timeout);
351 close_socket(sockfd);
374 int sockfd;
377 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_DGRAM,
383 return sockfd;
389 int sockfd;
392 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_DGRAM,
398 return sockfd;
407 int sockfd;
409 sockfd = ldns_udp_connect2(to, timeout);
411 if (sockfd == -1) {
415 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
416 close_socket(sockfd);
420 if (ldns_udp_send_query(qbin, sockfd, to, tolen) == 0) {
421 close_socket(sockfd);
424 return sockfd;
450 int sockfd;
453 sockfd = ldns_udp_bgsend_from(qbin, to, tolen, from, fromlen, timeout);
455 if (sockfd == -1) {
460 if(!ldns_sock_wait(sockfd, timeout, 0)) {
461 close_socket(sockfd);
468 ldns_sock_nonblock(sockfd);
470 answer = ldns_udp_read_wire(sockfd, answer_size, NULL, NULL);
471 close_socket(sockfd);
681 ldns_tcp_send_query(ldns_buffer *qbin, int sockfd,
693 bytes = sendto(sockfd, (void*)sendbuf,
706 ldns_udp_send_query(ldns_buffer *qbin, int sockfd, const struct sockaddr_storage *to,
711 bytes = sendto(sockfd, (void*)ldns_buffer_begin(qbin),
721 ldns_udp_read_wire(int sockfd, size_t *size, struct sockaddr_storage *from,
733 wire_size = recvfrom(sockfd, (void*)wire, LDNS_MAX_PACKETLEN, 0,
751 ldns_tcp_read_wire_timeout(int sockfd, size_t *size, struct timeval timeout)
764 if(!ldns_sock_wait(sockfd, timeout, 0)) {
769 rc = recv(sockfd, (void*) (wire + bytes),
790 if(!ldns_sock_wait(sockfd, timeout, 0)) {
795 rc = recv(sockfd, (void*) (wire + bytes),
810 ldns_tcp_read_wire(int sockfd, size_t *size)
823 rc = recv(sockfd, (void*) (wire + bytes),
844 rc = recv(sockfd, (void*) (wire + bytes),