• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sendString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sendString函数的典型用法代码示例。如果您正苦于以下问题:C++ sendString函数的具体用法?C++ sendString怎么用?C++ sendString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sendString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: receive

int receive(int socket)
{
	int msgLen = 0;
	char buffer[BUFFER_SIZE];

	memset (buffer,'\0', BUFFER_SIZE);

	if ((msgLen = recv(socket, buffer, BUFFER_SIZE, 0)) == -1)
	{
		printf("Error handling incoming request");
		return -1;
	}

	int request = getRequestType(buffer);

	if ( request == 1 )				// GET
	{
		handleHttpGET(buffer);
	}
	else if ( request == 2 )		// HEAD
	{
		// SendHeader();
	}
	else if ( request == 0 )		// POST
	{
		sendString("501 Not Implemented\n", connecting_socket);
	}
	else							// GARBAGE
	{
		sendString("400 Bad Request\n", connecting_socket);
	}

	return 1;
}
开发者ID:LailaShreteh,项目名称:GoHttp,代码行数:34,代码来源:GoHttp.c


示例2: openDataConnection

    void ClientThread::recvFile(const QString &filename){

        SOCKET conn = openDataConnection();
        if (conn == INVALID_SOCKET)
        {
            sendString(FTPProtocol::getInstance()->getResponse(425));
            return;
        }
        char buff[1024];
        int bytesReaded;
        QFile f(filename);
        if (!f.open(QIODevice::WriteOnly))
        {
            sendString(FTPProtocol::getInstance()->getResponse(550,"Can't open file"));
            return;
        }
        while( (bytesReaded = recv(conn, buff, 1024,0)) && (bytesReaded != -1))
        {
             f.write(buff, bytesReaded);
        }
        f.close();
        shutdown(conn,SD_BOTH);
        closesocket(conn);
        sendString(FTPProtocol::getInstance()->getResponse(226));
    }
开发者ID:peleccom,项目名称:SpoKursach,代码行数:25,代码来源:clientthread.cpp


示例3: initialize

void initialize()		///Works with current delays
{
	int result;
	result = enterCommandMode();
	sendString(GET_WLAN_STRING, 6);
	Delay10KTCYx(0);
	sendString(SET_SSID, 18);
	Delay10KTCYx(0);
	sendString(SET_PASSPHRASE, 29);
	Delay10KTCYx(0);
	sendString(SET_CHANNEL, 10);
	Delay10KTCYx(0);
	sendString(SET_AUTH, 10);
	Delay10KTCYx(0);
	sendString(SET_JOIN, 10);
	Delay10KTCYx(0);	
	sendString(SET_DHCP, 10);
	Delay10KTCYx(0);
	sendString(SET_COMM_OPEN, 10);
	Delay10KTCYx(0); 
	sendString(SET_COMM_REMOTE, 10);
	Delay10KTCYx(0);
	autoConnect();
	sendString(SAVE, 5);
	Delay10KTCYx(0);
	result = rebootModule();
	longDelay();
}
开发者ID:brianhrowe,项目名称:Digital_Foos,代码行数:28,代码来源:main.c


示例4: sendBreakpointEvent

/**
 * Sends a debug event to BinNavi.
 *
 * @param dbg The debug event to be sent.
 *
 * @return A NaviError code that describes whether the operation was successful
 * or not.
 **/
NaviError BaseConnection::sendDebugEvent(const DBGEVT *dbg) const {
  if (!dbg) {
    msglog->log(LOG_VERBOSE, "Error: Invalid debug event passed to function");
    return NaviErrors::INVALID_DEBUG_EVENT;
  }
  if (dbg->type == dbgevt_bp_hit || dbg->type == dbgevt_bpe_hit ||
      dbg->type == dbgevt_bps_hit) {
    return sendBreakpointEvent(dbg);
  } else if (dbg->type == dbgevt_bpe_rem) {
    return sendAddressReply(resp_bpe_rem_succ, 0, dbg->bp.addr);
  } else if (dbg->type == dbgevt_process_closed) {
    return sendProcessClosedEvent(dbg);
  } else if (dbg->type == dbgevt_thread_created) {
    return sendIntegerIntegerReply(resp_thread_created, 0, dbg->tid,
                                   dbg->extra);
  } else if (dbg->type == dbgevt_thread_closed) {
    return sendIntegerReply(resp_thread_closed, 0, dbg->tid);
  } else if (dbg->type == dbgevt_exception) {
    return sendString(resp_exception_occured, 0, dbg->registerString);
  } else if (dbg->type == dbgevt_module_loaded) {
    return sendString(resp_module_loaded, 0, dbg->registerString);
  } else if (dbg->type == dbgevt_module_unloaded) {
    return sendString(resp_module_unloaded, 0, dbg->registerString);
  } else if (dbg->type == dbgevt_process_start) {
    return sendString(resp_process_start, 0, dbg->registerString);
  }
  msglog->log(LOG_ALWAYS, "Error: Unknown debug event");
  return NaviErrors::UNKNOWN_DEBUG_EVENT;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:37,代码来源:BaseConnection.cpp


示例5: disconnect

bool IRC::connect(const std::string &serverName, int serverPort, const std::string &nick)
{
	disconnect();
	
	IPaddress ip;
	socketSet = SDLNet_AllocSocketSet(1);
	if (SDLNet_ResolveHost(&ip, (char *)serverName.c_str(), serverPort)==-1)
	{
		fprintf(stderr, "YOG : ResolveHost: %s\n", SDLNet_GetError());
		return false;
	}

	socket = SDLNet_TCP_Open(&ip);
	if (!socket)
	{
		fprintf(stderr, "YOG : TCP_Open: %s\n", SDLNet_GetError());
		return false;
	}

	SDLNet_TCP_AddSocket(socketSet, socket);
	
	// Here we change the nick on yog for the IRC
	// changing from nick = "nick" to YOGnick = "YOGnick"
	this->nick = "[YOG]" + nick;

	sendString("USER " + this->nick + " undef undef " + PACKAGE_TARNAME + "-" + PACKAGE_VERSION);
	sendString("NICK " + this->nick);

	return true;
}
开发者ID:krichter722,项目名称:glob2-git-hg,代码行数:30,代码来源:IRC.cpp


示例6: joinNetwork

int joinNetwork(){			///More Testing
	int retries;
	int offset;
	int result;
	if(inCommandMode == -1){
		result = enterCommandMode();
		if(result == -1)
			return -1;
		else
		inCommandMode = 1;
	}
	for(retries = 0; retries < RETRY_ATTEMPTS; retries++){
		sendString(JOIN_BOONDOCKS, 15);
		longDelay();
		sendString(SHOW_CONNECTION, 7);
		longDelay();		
		if(Txdata[0] != NULL){
			if(Txdata[2] == '3'){
				result = exitCommandMode();
				while(result != 1){
					result = exitCommandMode();
				}	
				return 1;
			}		
		}
	}
	result = exitCommandMode();
	return -1;
}	
开发者ID:brianhrowe,项目名称:Digital_Foos,代码行数:29,代码来源:main.c


示例7: main

int main(void){
	//int x=0;
	
	init_IO();
	init_Uart();
	startup_flashes_text();
	
	init_Timer2and3();
	init_OC2();
	
	
	while(1){
		PORTBbits.RB3=1;
		if(PORTBbits.RB0==1 && dutyCycle<1065){
			PORTBbits.RB3=0;
			sendString("increased duty cycle to ");
			dutyCycle+=5;
			OC2RS=dutyCycle;
			sendNum(dutyCycle);
			sendString(" \t(counterclockwise)\n\r");
			delay(10);
		}
		if(PORTBbits.RB1==1 && dutyCycle>110){
			PORTBbits.RB3=0;
			sendString(" decreased duty cycle to ");
			dutyCycle-=5;
			OC2RS=dutyCycle;
			sendNum(dutyCycle);
			sendString("\t(clockwise)\n\r");
			delay(10);
		}
	}
}
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:33,代码来源:main.c


示例8: send

    void send(zmq::socket_t& socket, const Message& message)
    {
      // Remember we're using the vector as a stack, so iterate through the
      // address in reverse.
      for (auto it = message.address.rbegin(); it != message.address.rend(); ++it)
      {
        sendStringPart(socket, *it);
      }

      // Send delimiter
      sendStringPart(socket, "");

      // Send subject, then data if there is any
      auto subjectString = detail::serialise<std::uint32_t>(message.subject);
      uint dataSize = message.data.size();
      if (dataSize > 0)
      {
        // The subject
        sendStringPart(socket, subjectString);

        // The data -- multipart
        for (auto it = message.data.begin(); it != std::prev(message.data.end()); ++it)
        {
          sendStringPart(socket, *it);
        }

        // final or only part
        sendString(socket, message.data.back());
      }
      else
      {
        // The subject
        sendString(socket, subjectString);
      }
    }
开发者ID:darrnshn,项目名称:stateline,代码行数:35,代码来源:transport.cpp


示例9: tr

void MainWindow::on_pushButton_clicked()
{   fname = QFileDialog::getOpenFileName(this, tr("Open File"),0,0);
    ui->label_3->setText("Calculating...");
    QThread *thread = new QThread;  // создаём поток... вначале он создаётся остановленным

    MyClass *job = new MyClass; // создаём экземпляр нашего класса
    job->moveToThread(thread);

    if(ui->rb_MD5->isChecked()){

        connect(thread,SIGNAL(started()),job,SLOT(MyCalcMD5())); // когда поток стартует, то начать выполнение работы нашего класса
        connect(job,SIGNAL(sendString(QString)),ui->lineEdit_2,SLOT(setText(QString)));
    }
    if(ui->rb_G2012->isChecked()){
       connect(thread,SIGNAL(started()),job,SLOT(GOST2012()));
       connect(job,SIGNAL(sendString(QString)),ui->lineEdit,SLOT(setText(QString)));
    }
    if(ui->rbSha256->isChecked()){
       connect(thread,SIGNAL(started()),job,SLOT(MyCalcSha256()));
       connect(job,SIGNAL(sendString(QString)),ui->lineEdit_3,SLOT(setText(QString)));
    }
    connect(job,SIGNAL(finished()),thread,SLOT(quit())); // когда работа будет завершена, завершить поток
            connect(job,SIGNAL(finished()),job,SLOT(deleteLater())); // когда работа будет завершена, удалить наш экземпляр класса
            connect(thread,SIGNAL(finished()),thread,SLOT(deleteLater())); // когда поток остановится, удалить его
thread->start();
connect(job,SIGNAL(change_value(int)),ui->progressBar_2,SLOT(setValue(int)));
connect(job,SIGNAL(set_max(int)),ui->progressBar_2,SLOT(setMaximum(int)));
connect(job,SIGNAL(sendStringDone(QString)),ui->label_3,SLOT(setText(QString)));
connect(job,SIGNAL(sendStringFileName(QString)),ui->label_2,SLOT(setText(QString)));

}
开发者ID:be1ay,项目名称:MyHash_Stribog,代码行数:31,代码来源:mainwindow.cpp


示例10: parse_ctc

int parse_ctc(char s[])
{
	char ctc[11];
	unsigned char i = 3, j = 0;

	while( (s[i] != '\0') && (j <= 11) ) 
	{
	
		if( (s[i] >= '0') && (s[i] <= '9') )
		{
			ctc[j++] = s[i++];
		}
		else
		{
			sendString("Error - Parse_ctc received a non integer: ");
			sendChar(s[i]);
			sendChar('\r');
			return 0;
		}
	}
	
	ctc[j] = '\0';
	
	if(j>4)// must be < 256
	{
		sendString("Error - Parse_ctc number too large");
		return 0;
	}
	else
	{
		set_ctc(atoi(ctc));
	}
		
	return 1;
}
开发者ID:bnnttlee,项目名称:CIS541_Pacemaker,代码行数:35,代码来源:Demonstrator.c


示例11: sendMatrix

/**
 * Sends the given matrix in plain text through the given socket.
 * Rows are delimited by newlines, columns by spaces.
 * \return zero on success; a non-zero error code on failure
 */
int sendMatrix(int sd, struct Matrix *mat)
{
    int i, j;
    char numBuf[50];
    int len;
    int err;

    for (i = 0; i < mat->height; ++i)
    {
        for (j = 0; j < mat->width; ++j)
        {
            /* snprintf() requires -std=c99 or later, so I can't
               use it.  So this isn't as safe as it should be. */
            len = sprintf(numBuf, "%d", mat->rows[i][j]);
            if (len < 0 || len == 50)
            {
                fprintf(stderr, "Buffer overflow converting %d to a string!\n",
                    mat->rows[i][j]);
                return ERANGE;
            }

            if ((err = sendString(sd, numBuf, len)))
                return err;
            if ((err = sendString(sd, " ", 1)))
                return err;
        }

        if ((err = sendString(sd, "\n", 1)))
            return err;
    }

    return 0;
}
开发者ID:pombredanne,项目名称:c_analyzer_zym,代码行数:38,代码来源:test2.c


示例12: homeScreen

void homeScreen(void) {

	int choice;
	
	const char *message = "\r\n\tWelcome to Light'o'matic 2000. Prepare for the most gripping PWM\r\n\texperience of your life.Prepare to have your mind blown.\r\n\r\n\tA\tChoose brightness\r\n\tB\tChoose animation\r\n\t\r\n\t";
	
	resetEmulator();

	sendNL();
	sendString(message);
	choice = waitForCharInput();
	
	resetEmulator();

	switch(choice) {
	 	case 'a':
		case 'A':
			menu_chooseBrightness();
		break;
		case 'b':
		case 'B':
			menu_chooseAnimation();
		break;
	}

	sendString("\r\n\t\r\n\t");

}
开发者ID:lawrencejob,项目名称:rtes,代码行数:28,代码来源:MAIN.C


示例13: procCmd6

//Get control gains
void procCmd6() {
    //Make sure we aren't running
    running = 0;
    //Tell PC we are ready to get control gains
    sendString("CONTROL\n");
    //Get control gains from PC
    //goes proportional (1/2/3), derivative (1/2/3), then integral (1/2/3)
    double gains[15];
    getDoublePacket(gains,15);
    kp1 = gains[0]; kp2 = gains[1]; kp3 = gains[2];
    kd1 = gains[3]; kd2 = gains[4]; kd3 = gains[5];
    ki1 = gains[6]; ki2 = gains[7]; ki3 = gains[8];
    INNER_K1_14 = gains[9]; INNER_K2_14 = gains[10];
    INNER_K1_11 = gains[11]; INNER_K2_11 = gains[12];
    INNER_K1_8  = gains[13]; INNER_K2_8  = gains[14];
    /* readDouble(&kp1); readDouble(&kp2); readDouble(&kp3); */
    /* readDouble(&kd1); readDouble(&kd2); readDouble(&kd3); */
    /* readDouble(&ki1); readDouble(&ki2); readDouble(&ki3); */
    /* readDouble(&INNER_K1_14); readDouble(&INNER_K2_14); */
    /* readDouble(&INNER_K1_11); readDouble(&INNER_K2_11); */
    /* readDouble(&INNER_K1_8); readDouble(&INNER_K2_8); */
//    readDouble(&kp1curr); readDouble(&kp2curr); readDouble(&kp3curr);
//    readDouble(&kd1curr); readDouble(&kd2curr); readDouble(&kd3curr);
    //Tell PC we are done with control gains
    sendString("GAINSUPDATED\n");
}
开发者ID:barberadam,项目名称:Manipulation,代码行数:27,代码来源:process_commands.c


示例14: setColour

void setColour(char foreground, char background){
	ASC0_vSendData(27);
	sendString("[3");
	ASC0_vSendData(foreground);
	ASC0_vSendData(27);
	sendString("[4");
	ASC0_vSendData(background);

}
开发者ID:lawrencejob,项目名称:rtes,代码行数:9,代码来源:MAIN.C


示例15: main

int main(void)
{
	SREG = 0x80;	/*ENABLE GLOBAL INTERRUPTS*/
	init_oscillator();
	init_usart();
	init_twi();
 //TWI_MASTER_t twi;
 //PMIC_CTRL= //interrupt
 
	PORTC.DIR |= PIN6_bm;
	
	if(( TWIC_MASTER_STATUS & TWI_MASTER_BUSSTATE_gm) == TWI_MASTER_BUSSTATE_IDLE_gc)
{	
	//TWIC_MASTER_ADDR =0x00; 
	TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;
	//TWIC_MASTER_CTRLC = TWI_MASTER_CMD_NOACT_gc;   //read data
	TWIC_MASTER_ADDR = 0xEC;  // R/W bit low to write the reg number from where we want to read
	TWIC_MASTER_ADDR = 0xA0;
	TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;
	TWIC_MASTER_ADDR = 0xED; // R/W bit high indicating a read operation 
    TWIC_MASTER_CTRLC = TWI_MASTER_CMD_STOP_gc;
	 int DATA=TWIC_MASTER_DATA;
	//sendChar(DATA);
	uint16_t buffer;
	itoa(DATA, buffer, 10);
	sendString(buffer);
	sendString("\n");
	
}

		//while(TWIC_MASTER_STATUS & 0x10)  //ack/NACK recieved from slave
 
//    TWIC_MASTER_ADDR =0x00; 
//    _delay_ms(100);
//    TWIC_MASTER_ADDR = 0xE7;
//      TWIC_MASTER_ADDR = 0xE5;
// 	 _delay_ms(100);
// TWIC_MASTER_ADDR = 0xA0;
    while(1)
	//for(int i=1; i<=5 ; i++)
    {
    
	 PORTC.OUT &= ~PIN6_bm;
  //  sendString("Test\n");
	_delay_ms(1000);
	PORTC.OUT |= PIN6_bm;
	_delay_ms(1000);
 
   //TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;

   int DATA=TWIC_MASTER_DATA;
	//sendChar(DATA);
	uint16_t buffer;
	itoa(DATA, buffer, 10);
//	sendString(buffer);
    }
}
开发者ID:deepikavira,项目名称:chemisense-board,代码行数:57,代码来源:i2c+trial.c


示例16: defineStateNoTime

void defineStateNoTime(int tripod, int tipo, int posicao){
	int i;
	for(i = 0; i<3; i++){
		sendString(servos[tripod][tipo][i]);
		sendString(" ");

		sendString(servoState[tripod][i][tipo][posicao]);
		sendString(" ");
	}
}
开发者ID:RobotColony-UEFS,项目名称:CH3-R,代码行数:10,代码来源:tripod.c


示例17: barcodez

int barcodez(int socket) {
  char tehfile[41];
  char safe[] = IMG_ROOT;
  char cobracmdr[sizeof(tehfile)+sizeof(safe)+9];
  char data[600];
  char safepath[sizeof(safe)+sizeof(tehfile)];
  int res = 0;

  memset(tehfile, 0x0, sizeof(tehfile));
  memset(cobracmdr, 0x0, sizeof(cobracmdr));
  memset(data, 0x0, sizeof(data));
  memset(safepath, 0x0, sizeof(safepath));

  sendString(socket, "Welcome to the data matrix bar code reader.\n");
  sendString(socket, "Enter the name of file uploaded to decode data.\n> ");

  if ((res = recvUntil(socket, tehfile, sizeof(tehfile) - 1, '\n')) == 0) {
    fprintf(stderr, "No datas!\n");
    close(socket);
    exit(1);
  }

  snprintf(safepath, sizeof(safepath), "%s%s", safe, tehfile);

  if ((res = validPath(safe, safepath)) == -1) {
    sendString(socket, "Hey! You can't look in there.\n");
    fprintf(stderr, "%s is outside the safe path.\n", safepath);
    close(socket);
    exit(1);
  }

  snprintf(cobracmdr, sizeof(cobracmdr), "dmtxread %s", safepath);

  if ((fp = popen(cobracmdr, "r")) == NULL) {
    perror("popen");
    close(socket);
    exit(1);
  }

  fread(data, SIZE, 1, fp);

  if (data[0] == 0x0) {
    sendString(socket, "Looks like you lost your file!\n");
    fprintf(stderr, "Nothing read!\n");
    close(socket);
    exit(1);
  }

  sendString(socket, data);

  fclose(fp);
  unlink(safepath);
  close(socket);
  return 0;
}
开发者ID:4v4t4r,项目名称:BroCTF,代码行数:55,代码来源:barcodez.c


示例18: printGoodResult

void printGoodResult(uint32_t result) {
    setPosition(0x28); //40 to pozycja pierwsza na dole
    sendString("Wynik: ");
    char tmp[5];
    int i= 0;
    for(i = 0; i < 5; i++) {
        tmp[i] = 0;
    }
    itoa(expectedResult, tmp, 10);
    sendString(tmp);
}
开发者ID:piotrplaneta,项目名称:RTS,代码行数:11,代码来源:project.c


示例19: endGame

void endGame() { //konczenie gry
	isStarted = 0; //zatrzymujemy gre
	isEnded = 1; //konczymy
	player = 1; //zmieniamy gracza do nastepnej rozgrywki na 1
	updateDisplay(9999);
	if (playerOneTime < playerTwoTime) { //wygral gracz pierwszy
		USART_Transmit_String("Wygrywa Gracz 1! Gratulacje!");
		USART_Transmit(10); //nowa linia
		USART_Transmit(13); //powrot karetki
	} else if(playerOneTime > playerTwoTime) {
		USART_Transmit_String("Wygrywa Gracz 2! Gratulacje!");
		USART_Transmit(10); //nowa linia
		USART_Transmit(13); //powrot karetki
	} else {
		USART_Transmit_String("Remis! Gratulacje!");
		USART_Transmit(10); //nowa linia
		USART_Transmit(13); //powrot karetki
	}
    
	USART_Transmit_String("Czas gracza pierwszego: ");
	char tmp[5];
	int i= 0;
	for(i = 0; i < 5; i++) {
		tmp[i] = 0;
	}
	itoa(playerOneTime, tmp, 10);
	USART_Transmit_String(tmp);
	USART_Transmit(10); //nowa linia
	USART_Transmit(13); //powrot karetki
	USART_Transmit_String("Czas gracza drugiego: ");
	for(i = 0; i < 5; i++) {
		tmp[i] = 0;
	}
	itoa(playerTwoTime, tmp, 10);
	USART_Transmit_String(tmp);
	USART_Transmit(10); //nowa linia
	USART_Transmit(13); //powrot karetki
	USART_Transmit_String("Roznica: ");
	for(i = 0; i < 5; i++) {
		tmp[i] = 0;
	}
	itoa(calculateDistance(playerOneTime, playerTwoTime), tmp, 10);
	USART_Transmit_String(tmp);
	USART_Transmit(10); //nowa linia
	USART_Transmit(13); //powrot karetki
    
	playerOneTime = 0; //zerujemy czasy obu graczy
	playerTwoTime = 0;
	clearAndSetZeroPosition(); //czyscimy wyswietlacz i wracamy na poczatek
	sendString("Jeszcze raz?");
	setPosition(0x28); //40 to pozycja pierwsza na dole
	sendString("Wcisnij klawisz");
}
开发者ID:piotrplaneta,项目名称:RTS,代码行数:53,代码来源:project.c


示例20: sendFile

/**
 * @brief Send a file
 * @param sockfd remote socket to send to
 * @param *file_name Name of the file to send
 * @return send bytes or negative on failure
 */
int sendFile(int sockfd, char *file_name)
{

    int file, length;
    //Pointer to play with
    char * ptr;
    //Backup pointer to ptr
    char * bPtr;

    //Open file and get the filesize
    if((file = open(file_name, O_RDONLY, 0)) == -1)
        return -1;
    length = get_file_size(file);

    //Start sending the HTTP file headers
    int header_length = strlen("Content-Length: ") + 5;
    char length_header[header_length];
    snprintf(length_header, header_length ,"Content-Length: %d\r\n", length);
    sendString(sockfd, length_header);
    //TODO: Different file support
    char filetype_format[] = "Content-Type: %s; charset=UTF-8\r\n";
    char filetype[] = "text/html";
    char * filetype_header =
        object_ninit((strlen(filetype_format) + strlen(filetype) - 1) * sizeof(char));
    sprintf(filetype_header, filetype_format, filetype);

    sendString(sockfd, filetype_header);
    free(filetype_header);

    sendString(sockfd, "\r\n");

    if((ptr = malloc(length * sizeof(char))) == NULL)
        return -1;
    bPtr = ptr;
    if(read(file, ptr, length) == -1)
        return -1;

    int send_bytes = 0;
    int bytes_to_send = length;

    while(bytes_to_send > 0){
        send_bytes = send(sockfd, ptr, bytes_to_send, 0);
        if(send_bytes == -1)
            return -1;
        bytes_to_send -= send_bytes;
        ptr += send_bytes;
    }
    //Free the original ptr
    free(bPtr);
    //Return the send_bytes 
    return send_bytes;

}
开发者ID:Factionwars,项目名称:evilwebserver,代码行数:59,代码来源:evilnetlib.c



注:本文中的sendString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sendToClient函数代码示例发布时间:2022-05-30
下一篇:
C++ sendSignal函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap