bool TCP_Transporter::doSend() { // If no sendbuffers are used nothing is done // Sends the contents of the SendBuffers until they are empty // or until select does not select the socket for write. // Before calling send, the socket must be selected for write // using "select" // It writes on the external TCP/IP interface until the send buffer is empty // and as long as write is possible (test it using select) // Empty the SendBuffers bool sent_any = true; while (m_sendBuffer.dataSize > 0) { const char * const sendPtr = m_sendBuffer.sendPtr; const Uint32 sizeToSend = m_sendBuffer.sendDataSize; const int nBytesSent = inet_send(theSocket, sendPtr, sizeToSend, 0); if (nBytesSent > 0) { sent_any = true; m_sendBuffer.bytesSent(nBytesSent); sendCount ++; sendSize += nBytesSent; if(sendCount == reportFreq) { reportSendLen(get_callback_obj(), remoteNodeId, sendCount, sendSize); sendCount = 0; sendSize = 0; } } else { if (nBytesSent < 0 && InetErrno == EAGAIN && sent_any) break; // Send failed #if defined DEBUG_TRANSPORTER ndbout_c("Send Failure(disconnect==%d) to node = %d nBytesSent = %d " "errno = %d strerror = %s", DISCONNECT_ERRNO(InetErrno, nBytesSent), remoteNodeId, nBytesSent, InetErrno, (char*)ndbstrerror(InetErrno)); #endif if(DISCONNECT_ERRNO(InetErrno, nBytesSent)){ doDisconnect(); report_disconnect(InetErrno); } return false; } } return true; }
static int inet_write(struct socket *sock, char *ubuf, int size, int noblock) { return inet_send(sock,ubuf,size,noblock,0); }
long google_query(char *gooflag, char *type, char *value ) { extern char pretty_query[1024]; //a human-readable version extern char mid_query[1024];//a version for the web server extern char *site; extern char *xtra_stuff; extern char total_string[256]; extern int sflag; extern int vflag; extern long results; char scratch[1024]; if (strlen(total_string) ==0) { //printf("null total string"); sprintf(total_string,"%s:%s",type,value); } if (vflag) printf("(verbose) command line query => %s\n",value); if (strcmp(gooflag,"indexof") ==0 ) { sprintf(pretty_query, "intitle:index.of+%s",value); } else if (strcmp(gooflag,"inurl") ==0 ) { sprintf(pretty_query, "inurl:%s",value); } else if (strcmp(gooflag,"intitle") ==0 ) { sprintf(pretty_query, "intitle:%s",value); } else if (strcmp(gooflag,"raw") ==0 ) sprintf(pretty_query,"%s",value); else if (strcmp(gooflag,"filetype") ==0) { sprintf(pretty_query,"filetype:%s",value); } else return(-1); // pretty_query will not have any of the below ugliness sprintf(mid_query,"&q=%s",pretty_query); if (sflag) { sprintf(scratch,"%s+site:%s",mid_query,site); strncpy(mid_query,scratch,1024); if (vflag) printf("(verbose) site added. query is now: %s\n",mid_query); } if (xflag) { sprintf(scratch,"%s&%s",mid_query,xtra_stuff); strncpy(mid_query,scratch,1024); if (vflag) printf("(verbose) extra stuff added. query is now: %s\n",mid_query); } if (vflag) printf("(verbose) Sending query => %s\n",mid_query); if (inet_send(mid_query) == 1) { printf("Error sending query.\n"); return(0); } else { results=parse_results(recvbuf); } sprintf(scratch,"%s %s:%ld ",total_string,gooflag,results); strncpy(total_string,scratch,256); total+=results; return(results); }