Lines Matching refs:sockfd

110 ldns_sock_nonblock(int sockfd)
114 if((flag = fcntl(sockfd, F_GETFL)) != -1) {
116 if(fcntl(sockfd, F_SETFL, flag) == -1) {
122 if(ioctlsocket(sockfd, FIONBIO, &on) != 0) {
130 ldns_sock_block(int sockfd)
134 if((flag = fcntl(sockfd, F_GETFL)) != -1) {
136 if(fcntl(sockfd, F_SETFL, flag) == -1) {
142 if(ioctlsocket(sockfd, FIONBIO, &off) != 0) {
150 ldns_sock_wait(int sockfd, struct timeval timeout, int write)
156 FD_SET(FD_SET_T sockfd, &fds);
158 ret = select(sockfd+1, NULL, &fds, NULL, &timeout);
160 ret = select(sockfd+1, &fds, NULL, NULL, &timeout);
177 int sockfd;
180 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_STREAM,
185 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
190 ldns_sock_nonblock(sockfd);
191 if (connect(sockfd, (struct sockaddr*)to, tolen) == -1) {
198 close(sockfd);
204 closesocket(sockfd);
216 if(!ldns_sock_wait(sockfd, timeout, 1)) {
218 close(sockfd);
220 closesocket(sockfd);
226 if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)&error,
240 close(sockfd);
251 closesocket(sockfd);
261 ldns_sock_block(sockfd);
263 return sockfd;
279 int sockfd;
281 sockfd = ldns_tcp_connect_from(to, tolen, from, fromlen, timeout);
283 if (sockfd == 0) {
287 if (ldns_tcp_send_query(qbin, sockfd, to, tolen) == 0) {
289 close(sockfd);
291 closesocket(sockfd);
296 return sockfd;
317 int sockfd;
320 sockfd = ldns_tcp_bgsend_from(qbin, to, tolen, from, fromlen, timeout);
322 if (sockfd == 0) {
326 answer = ldns_tcp_read_wire_timeout(sockfd, answer_size, timeout);
328 close(sockfd);
330 closesocket(sockfd);
359 int sockfd;
362 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_DGRAM,
368 return sockfd;
377 int sockfd;
379 sockfd = ldns_udp_connect(to, timeout);
381 if (sockfd == 0) {
385 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
389 if (ldns_udp_send_query(qbin, sockfd, to, tolen) == 0) {
391 close(sockfd);
393 closesocket(sockfd);
397 return sockfd;
414 int sockfd;
417 sockfd = ldns_udp_bgsend_from(qbin, to, tolen, from, fromlen, timeout);
419 if (sockfd == 0) {
424 if(!ldns_sock_wait(sockfd, timeout, 0)) {
426 close(sockfd);
428 closesocket(sockfd);
436 ldns_sock_nonblock(sockfd);
438 answer = ldns_udp_read_wire(sockfd, answer_size, NULL, NULL);
440 close(sockfd);
442 closesocket(sockfd);
648 ldns_tcp_send_query(ldns_buffer *qbin, int sockfd,
660 bytes = sendto(sockfd, (void*)sendbuf,
673 ldns_udp_send_query(ldns_buffer *qbin, int sockfd, const struct sockaddr_storage *to,
678 bytes = sendto(sockfd, (void*)ldns_buffer_begin(qbin),
691 ldns_udp_read_wire(int sockfd, size_t *size, struct sockaddr_storage *from,
703 wire_size = recvfrom(sockfd, (void*)wire, LDNS_MAX_PACKETLEN, 0,
721 ldns_tcp_read_wire_timeout(int sockfd, size_t *size, struct timeval timeout)
734 if(!ldns_sock_wait(sockfd, timeout, 0)) {
739 rc = recv(sockfd, (void*) (wire + bytes),
760 if(!ldns_sock_wait(sockfd, timeout, 0)) {
765 rc = recv(sockfd, (void*) (wire + bytes),
780 ldns_tcp_read_wire(int sockfd, size_t *size)
793 rc = recv(sockfd, (void*) (wire + bytes),
814 rc = recv(sockfd, (void*) (wire + bytes),