Lines Matching refs:sock
115 TCPSocket *sock; // socket connected to client
238 mDNSlocal mStatus AddSourceToEventLoop( DaemonInfo * self, TCPSocket *sock, EventCallback callback, void *context )
257 newSource->sock = sock;
258 newSource->fd = mDNSPlatformTCPGetFD( sock );
270 mDNSlocal mStatus RemoveSourceFromEventLoop( DaemonInfo * self, TCPSocket *sock )
277 if ( source->sock == sock )
305 TCPSocket *sock = mDNSPlatformTCPSocket( NULL, 0, &port );
306 if ( !sock ) { LogErr("ConnectToServer", "socket"); return NULL; }
307 fd = mDNSPlatformTCPGetFD( sock );
308 if (!connect( fd, (struct sockaddr *)&d->ns_addr, sizeof(d->ns_addr))) return sock;
309 mDNSPlatformTCPCloseConnection( sock );
323 mDNSlocal int MySend(TCPSocket *sock, const void *msg, int len)
335 fd = mDNSPlatformTCPGetFD( sock );
342 n = mDNSPlatformWriteTCP( sock, ( char* ) msg + nsent, len - nsent);
351 mDNSlocal int SendPacket(TCPSocket *sock, PktMsg *pkt)
355 if (MySend(sock, &len, sizeof(len)) < 0) return -1;
363 return MySend(sock, &pkt->msg, pkt->len);
368 static int my_recv(TCPSocket *sock, void *const buf, const int len, mDNSBool * closed)
385 fd = mDNSPlatformTCPGetFD( sock );
397 num_read = mDNSPlatformReadTCP( sock, ptr, remaining, closed );
415 TCPSocket * sock,
428 fd = mDNSPlatformTCPGetFD( sock );
430 nread = my_recv( sock, &msglen, sizeof( msglen ), closed );
470 nread = my_recv(sock, &pkt->msg, msglen, closed );
910 TCPSocket *sock = NULL;
914 sock = ConnectToServer( d );
915 require_action( sock, exit, err = mStatus_UnknownErr; Log( "UpdateSRV: ConnectToServer failed" ) );
982 err = SendPacket( sock, &pkt );
985 reply = RecvPacket( sock, NULL, &closed );
1000 if ( sock )
1002 mDNSPlatformTCPCloseConnection( sock );
1292 mDNSlocal void DeleteOneRecord(DaemonInfo *d, CacheRecord *rr, domainname *zname, TCPSocket *sock)
1324 if (SendPacket( sock, &pkt)) { Log("DeleteOneRecord: SendPacket failed"); }
1325 reply = RecvPacket( sock, NULL, &closed );
1342 TCPSocket *sock = ConnectToServer(d);
1343 if (!sock) { Log("DeleteRecords: ConnectToServer failed"); return; }
1356 DeleteOneRecord(d, &(*ptr)->rr, &(*ptr)->zone, sock);
1366 mDNSPlatformTCPCloseConnection( sock );
1514 TCPSocket * sock = NULL;
1571 sock = ConnectToServer( self );
1572 require_action_quiet( sock, exit, err = mStatus_UnknownErr ; Log( "Discarding request from %s due to connection errors", inet_ntop( AF_INET, &request->src.sin_addr, addrbuf, 32 ) ) );
1574 res = SendPacket( sock, request );
1577 reply = RecvPacket( sock, &buf, &closed );
1616 if ( sock )
1618 mDNSPlatformTCPCloseConnection( sock );
1709 mDNSlocal int SendLLQ(DaemonInfo *d, PktMsg *pkt, struct sockaddr_in dst, TCPSocket *sock)
1716 if ( sock )
1718 if ( SendPacket( sock, pkt ) != 0 )
1742 TCPSocket *sock = NULL;
1775 sock = ConnectToServer(d);
1776 if (!sock) { Log("AnswerQuestion: ConnectToServer failed"); goto end; }
1777 if (SendPacket( sock, &q)) { Log("AnswerQuestion: SendPacket failed"); mDNSPlatformTCPCloseConnection( sock ); goto end; }
1778 reply = RecvPacket( sock, NULL, &closed );
1779 mDNSPlatformTCPCloseConnection( sock );
2119 mDNSlocal void LLQRefresh(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID, TCPSocket *sock )
2148 if (SendLLQ(d, &ack, e->cli, sock)) Log("Error: LLQRefresh");
2155 mDNSlocal void LLQCompleteHandshake(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID, TCPSocket *sock)
2202 if (SendLLQ(d, &ack, e->cli, sock)) Log("Error: LLQCompleteHandshake");
2240 mDNSlocal void UpdateLLQ(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID, TCPSocket *sock )
2245 if ( sock )
2252 LLQCompleteHandshake( d, e, llq, msgID, sock );
2264 else LLQCompleteHandshake(d, e, llq, msgID, sock );
2277 { LLQCompleteHandshake(d, e, llq, msgID, sock); return; } // Ack lost
2279 { LLQRefresh(d, e, llq, msgID, sock); return; }
2321 mDNSlocal int RecvLLQ( DaemonInfo *d, PktMsg *pkt, TCPSocket *sock )
2375 UpdateLLQ(d, e, llq, pkt->msg.h.id, sock);
2660 if ( context->sock )
2662 mDNSPlatformTCPCloseConnection( context->sock );
2689 res = SendPacket( context->sock, reply );
2725 pkt = RecvPacket( context->sock, &context->pkt, &closed );
2735 RemoveSourceFromEventLoop( context->d, context->sock );
2749 RecvLLQ( context->d, &context->pkt, context->sock);
2780 SendPacket( context->sock, &reply );
2792 RemoveSourceFromEventLoop( context->d, context->sock );
2822 context->sock = mDNSPlatformTCPAccept( flags, newSock );
2823 require_action( context->sock, exit, err = mStatus_UnknownErr; LogErr( "AcceptTCPConnection", "mDNSPlatformTCPAccept" ) );
2825 err = AddSourceToEventLoop( self, context->sock, RecvTCPMessage, context );