/*发送透明传输数据*/ bool CVechileMgr::SendTransparentMsg(_stVechile *p , int ncount,unsigned short wType) { if( ncount <= 0 ) { return false ; } DataBuffer transport_buf; TransHeader header; int nLen = _logistics->BuildTransportData(wType,transport_buf); OUT_HEX(NULL, 0, "Transport", transport_buf.getBuffer(),transport_buf.getLength()); BuildHeader(header.header, 0x900,nLen, p); DataBuffer sendbuf; sendbuf.writeBlock(&header, sizeof(header)); sendbuf.writeBlock(transport_buf.getBuffer(), transport_buf.getLength()); unsigned short mlen = (sendbuf.getLength()-sizeof(GBheader)) & 0x03FF ; sendbuf.fillInt16( mlen, 3 ) ; GBFooter footer ; sendbuf.writeBlock(&footer, sizeof(footer) ) ; if ( ! Send5BData( p->fd_, sendbuf.getBuffer(), sendbuf.getLength() ) ) { p->car_state_ = OFF_LINE ; return false ; } p->lgs_time_ = share::Util::currentTimeUsec() ; return true ; }
void HttpResponse::SendFile(int socket,string filename) { // cout << "Send:" << filename << endl; ifstream ifs(filename, ios::binary|ios::ate); if (!ifs){ return; } deque<string> FileToks = String::Split(string(filename.c_str())+"", '.'); if(FileToks.size()>1){ FileToks.pop_back(); contentType = FileToks.front(); } else { contentType = "text/html"; } ifstream::pos_type pos = ifs.tellg(); vector<char> bytes(pos); ifs.seekg(0, ios::beg); ifs.read(&bytes[0], pos); string s = BuildHeader(bytes.size()); vector<char> r(s.begin(),s.end()); r.insert(r.end(),bytes.begin(),bytes.end()); send(socket, &r[0], r.size(),0); ifs.close(); }
/*------------------------------------------------------------------* * MODIFICATIONS * * Date Description Author * * =========== ================================== =============== * * * *------------------------------------------------------------------*/ ZRESULT ZFilePacket::Build() { BEG_FUNC("Build")(NULL); ZSP_FILE_PACKET *vFile; if (mImageId == "" || mImageDate == "" || mImageName == "") { ZERROR("Necessary values have not been set (id/date/name)\n"); return END_FUNC(ZERR_INVALID_STATUS); } /* * Build the outgoing FLAG packet */ mPacketLen = FILE_SIZE + mImageName.length(); vFile = reinterpret_cast<ZSP_FILE_PACKET *>(BuildHeader()); memcpy(vFile->image_id, mImageId.c_str(), ZMIN(sizeof(vFile->image_id), mImageId.length())); vFile->image_format = htonl(mImageFormat); vFile->image_size = htonl(mImageSize); memcpy(vFile->image_date, mImageDate.c_str(), ZMIN(sizeof(vFile->image_date), mImageDate.length())); memcpy(&mRaw[FILE_SIZE], mImageName.c_str(), mImageName.length());\ return END_FUNC(ZERR_SUCCESS); }
/// Builds a default header if it doesn't exist. void SIPPacket::EnsureHeader(){ if (header.Size() != 0) return; // Assign default-sender if not done already. if (sender == NULL) SetSender(defaultSender); // Build it. BuildHeader(); }
bool InstructThread::StartHeartbeat(const Address & Server) { Instruction * p = new Instruction; BuildHeader(p, IPV4 | LOCAL_ADDRESS, Server.m_IPv4, Server.m_Port, HEARTBEAT_INTERVAL, 0x0); Packet * packet = &p->Data; BuildHeartbeat(packet, p->Identify); return PushInst(p); }
bool InstructThread::Login(const Address & Server, const std::string & Username, const std::string & Passwd) { Instruction * p = new Instruction; BuildHeader(p, IPV4 | LOCAL_ADDRESS, Server.m_IPv4, Server.m_Port, 1, MAX_LOGIN_RETRY); Packet * packet = &p->Data; BuildLoginRequest(packet, Username, Passwd, p->Identify); return PushInst(p); }
/*------------------------------------------------------------------* * MODIFICATIONS * * Date Description Author * * =========== ================================== =============== * * * *------------------------------------------------------------------*/ ZRESULT ZVersRespPacket::Build() { BEG_FUNC("Build")(""); ZSP_VERSION_RESP_PACKET *vVersResp; /* * Build the outgoing VERSION_RESPONSE packet */ mPacketLen = VERSION_RESP_SIZE + mReturnText.length(); vVersResp = reinterpret_cast<ZSP_VERSION_RESP_PACKET *>(BuildHeader()); vVersResp->return_code = htons(mReturnCode); memcpy(&mRaw[VERSION_RESP_SIZE], mReturnText.c_str(), mReturnText.length()); return END_FUNC(ZERR_SUCCESS); }
/*------------------------------------------------------------------* * MODIFICATIONS * * Date Description Author * * =========== ================================== =============== * * * *------------------------------------------------------------------*/ ZRESULT ZFileRespPacket::Build() { BEG_FUNC("Build")(NULL); ZSP_FILE_RESP_PACKET *vFileResp; /* * Build the outgoing FILE_RESPONSE packet */ mPacketLen = FILE_RESP_SIZE + mReturnText.length(); vFileResp = reinterpret_cast<ZSP_FILE_RESP_PACKET *>(BuildHeader()); memcpy(vFileResp->image_id, mImageId.c_str(), ZMIN(mImageId.length(), sizeof(vFileResp->image_id))); vFileResp->return_code = htons(mReturnCode); memcpy(&mRaw[FILE_RESP_SIZE], mReturnText.c_str(), mReturnText.length()); return END_FUNC(ZERR_SUCCESS); }
/*------------------------------------------------------------------* * MODIFICATIONS * * Date Description Author * * =========== ================================== =============== * * * *------------------------------------------------------------------*/ ZRESULT ZDonePacket::Build() { BEG_FUNC("Build")(NULL); ZSP_DONE_PACKET *vDone; if (mImageId == "") { ZERROR("Necessary values have not been set (image id)\n"); return END_FUNC(ZERR_INVALID_STATUS); } /* * Build the outgoing DONE packet */ mPacketLen = DONE_SIZE; vDone = reinterpret_cast<ZSP_DONE_PACKET *>(BuildHeader()); memcpy(vDone->image_id, mImageId.c_str(), ZMIN(mImageId.length(), sizeof(vDone->image_id))); return END_FUNC(ZERR_SUCCESS); }
void GffFileWriter::CommitInternal( __in GffWriteContext * Context, __in unsigned long FileType, __in unsigned long Flags ) /*++ Routine Description: This routine writes the staged GFF contents to a write context, which may represent a disk file or an in-memory buffer. Arguments: Context - Supplies the write context that receives the contents of the formatted GFF file. FileType - Supplies the type tag of the file (GFF, BIC, etc.) Flags - Supplies flags that control the behavior of the commit operation. Legal values are drawn from the GFF_COMMIT_FLAG_* family of values. Return Value: None. The routine raises an std::exception on failure. Environment: User mode. --*/ { GFF_HEADER Header; FieldStructPtrVec Structs; // // If the user did not supply an override file type, take the default one. // if (FileType == 0) FileType = m_FileType; m_RootStruct->StructType = 0xFFFFFFFF; // // First, generate and store the header. // BuildHeader( Header, FileType ); Context->Write( &Header, sizeof( Header ) ); // // First, we write the labels out. // Header.LabelOffset = sizeof( Header ); WriteLabelEntries( Header, Context ); // // Write the field data section out next. // if (Header.LabelOffset + Header.LabelCount * sizeof( GFF_LABEL_ENTRY ) < Header.LabelOffset) throw std::runtime_error( "GFF file is too large." ); Header.FieldDataOffset = Header.LabelOffset + (Header.LabelCount * sizeof( GFF_LABEL_ENTRY )); WriteFieldData( Header, Context ); // // Now write out the field data indicies, since we have assigned these as // a part of the field data write process. // Header.FieldIndiciesOffset = Header.FieldDataOffset + Header.FieldDataCount; if (Header.FieldDataOffset + Header.FieldDataCount < Header.FieldDataOffset) throw std::runtime_error( "GFF file is too large." ); WriteFieldIndicies( Header, Context ); // // Write structures. // if (Header.FieldIndiciesOffset + Header.FieldIndiciesCount < Header.FieldIndiciesOffset) throw std::runtime_error( "GFF file is too large." ); Header.StructOffset = Header.FieldIndiciesOffset + Header.FieldIndiciesCount; WriteStructEntries( Header, Context ); // // Write list indicies. // if (Header.StructOffset + (Header.StructCount * sizeof( GFF_STRUCT_ENTRY )) < Header.StructOffset) throw std::runtime_error( "GFF file is too large." ); Header.ListIndiciesOffset = Header.StructOffset + (Header.StructCount * sizeof( GFF_STRUCT_ENTRY )); WriteListIndicies( Header, Context ); // // Write the field descriptors out. // if (Header.ListIndiciesOffset + Header.ListIndiciesCount < Header.ListIndiciesOffset) throw std::runtime_error( "GFF file is too large." ); Header.FieldOffset = Header.ListIndiciesOffset + Header.ListIndiciesCount; WriteFieldEntries( Header, Context ); // // Finally, re-write the updated header. // Context->SeekOffset( 0, "Write Finalized Header" ); Context->Write( &Header, sizeof( Header ) ); if (Flags & GFF_COMMIT_FLAG_SEQUENTIAL) { GFF_HEADER NewHeader; std::vector< unsigned char > OrderedContents; // // If we must arrange the fields in sequential order, i.e. to work around // buggy GFF readers, then stitch up the final file here. // OrderedContents.resize( Header.FieldOffset + (Header.FieldCount * sizeof( GFF_FIELD_ENTRY ) ) ); // // Build the new header up now. // NewHeader = Header; NewHeader.StructOffset = sizeof( NewHeader ); NewHeader.FieldOffset = NewHeader.StructOffset + (NewHeader.StructCount * sizeof( GFF_STRUCT_ENTRY )); NewHeader.LabelOffset = NewHeader.FieldOffset + (NewHeader.FieldCount * sizeof( GFF_FIELD_ENTRY )); NewHeader.FieldDataOffset = NewHeader.LabelOffset + (NewHeader.LabelCount * sizeof( GFF_LABEL_ENTRY )); NewHeader.FieldIndiciesOffset = NewHeader.FieldDataOffset + (NewHeader.FieldDataCount); NewHeader.ListIndiciesOffset = NewHeader.FieldIndiciesOffset + (NewHeader.FieldIndiciesCount); memcpy( &OrderedContents[ 0 ], &NewHeader, sizeof( NewHeader ) ); // // Now copy each section over from the previous write context. // Context->Read( &OrderedContents[ NewHeader.LabelOffset ], NewHeader.LabelCount * sizeof( GFF_LABEL_ENTRY )); Context->Read( &OrderedContents[ NewHeader.FieldDataOffset ], NewHeader.FieldDataCount); Context->Read( &OrderedContents[ NewHeader.FieldIndiciesOffset ], NewHeader.FieldIndiciesCount ); Context->Read( &OrderedContents[ NewHeader.StructOffset ], NewHeader.StructCount * sizeof( GFF_STRUCT_ENTRY )); Context->Read( &OrderedContents[ NewHeader.ListIndiciesOffset ], NewHeader.ListIndiciesCount); Context->Read( &OrderedContents[ NewHeader.FieldOffset ], NewHeader.FieldCount * sizeof( GFF_FIELD_ENTRY )); // // Now transfer the sequentially ordered contents back over to the writer // context for persistence. // Context->SeekOffset( 0, "Write Sequentialized File Contents" ); Context->Write( &OrderedContents[ 0 ], OrderedContents.size( ) ); } #if !GFFFILEWRITER_PRETRACK_STRUCTS // // If we are not pre-tracking structures, clear out the references that we // created on the fly for fast structure lookup. // m_Structs.clear( ); #endif }
void HttpResponse::Send(int socket){ string s = BuildHeader(data.length()) +data; send(socket, s.c_str(), s.size()+1,0); }
/* ARGSUSED */ void SetCommand(Widget w, ResCommand command, char *msg) { XClientMessageEvent client_event; Display *dpy = XtDisplay(w); if (msg == NULL) { /* "Click the mouse pointer on any toolkit client" */ msg = res_labels[6]; } SetMessage(global_screen_data.info_label, msg, "Click the mouse pointer on any toolkit client"); if (global_client.window == None) { if ( (global_client.window = GetClientWindow(w, NULL, NULL)) == None ) { return; } } /* printf("[SetCommand] global_client.window: %d 0x%x\n", */ /* global_client.window, */ /* global_client.window); */ global_client.ident = GetNewIdent(); global_client.command = command; global_client.atom = atom_comm; BuildHeader(&(global_client)); if (!XtOwnSelection(w, global_client.atom, CurrentTime, ConvertCommand, LoseSelection, SelectionDone)) { /* "Unable to own the Resource/Attribute Selection" */ SetMessage(global_screen_data.info_label, res_labels[7], "Unable to own the Resource/Attribute Selection"); } client_event.window = global_client.window; client_event.type = ClientMessage; client_event.message_type = atom_resource_editor; client_event.format = EDITRES_SEND_EVENT_FORMAT; client_event.data.l[0] = XtLastTimestampProcessed(dpy); client_event.data.l[1] = global_client.atom; client_event.data.l[2] = (long) global_client.ident; client_event.data.l[3] = global_effective_protocol_version; global_error_code = NO_ERROR; /* Reset Error code. */ global_old_error_handler = XSetErrorHandler(HandleXErrors); global_serial_num = NextRequest(dpy); XSendEvent(dpy, global_client.window, FALSE, (long)0, (XEvent*)&client_event); XSync(dpy, FALSE); XSetErrorHandler(global_old_error_handler); if (global_error_code == NO_WINDOW) { char error_buf[BUFSIZ]; global_error_code = NO_ERROR; /* Reset Error code. */ sprintf(error_buf, "The communication window with%s%s.", " application is no longer available\n", "Please select a new widget tree"); global_client.window = None; SetCommand(w, LocalSendWidgetTree, error_buf); return; } TellUserAboutMessage(global_screen_data.info_label, command); global_client.timeout = XtAppAddTimeOut(XtWidgetToApplicationContext(w), CLIENT_TIME_OUT, ClientTimedOut, (XtPointer)w); startWait(XtWidgetToApplicationContext(w), CLIENT_TIME_OUT / 1000); } /* SetCommand() */
bool CVechileMgr::SendLocationPos( _stVechile *p , int ncount ) { if( ncount <= 0 || p == NULL ) { return false ; } time_t now = share::Util::currentTimeUsec() ; srand( now ) ; int nrand = rand() ; // 产生随机报警 DataBuffer buf ; TermLocationHeader header ; BuildHeader( header.header, 0x200 , sizeof(GpsInfo), p ) ; unsigned int alarm = 0 ; if ( now - p->last_alam_ > _alam_time && _alam_time > 0 ) { alarm = htonl( nrand ) ; p->last_alam_ = now ; } memcpy( &header.gpsinfo.alarm, &alarm, sizeof(unsigned int) ) ; unsigned int state = 0 ; memcpy( &header.gpsinfo.state , &state, sizeof(unsigned int) ) ; int pos = p->gps_pos_ ; pos = pos + 1 ; pos = pos % ncount ; Point &pt = _gps_vec[pos] ; header.gpsinfo.heigth = htons(nrand%100) ; header.gpsinfo.speed = htons(get_car_speed());//htons(nrand%1000) ; header.gpsinfo.direction = htons(nrand%360) ; // 取得当前BCD的时间 get_bcd_time( header.gpsinfo.date_time ) ; if(header.gpsinfo.speed == 0) { header.gpsinfo.state.bit6 = 0; header.gpsinfo.state.bit7 = 0; header.gpsinfo.longitude = 0 ; header.gpsinfo.latitude = 0 ; } else { header.gpsinfo.state.bit6 = 1; header.gpsinfo.state.bit7 = 1; header.gpsinfo.longitude = htonl( pt.lon ) ; header.gpsinfo.latitude = htonl( pt.lat ) ; } buf.writeBlock( &header, sizeof(header) ) ; // 需要上传CAN的数据 if ( now - p->last_candata_ > _candata_time && _candata_time > 0 ) { p->last_candata_ = now ; int index = nrand % 5; write_dword( buf, 0x01, 2000 ) ; write_word( buf, 0x02, 100 ) ; write_word( buf, 0x03, 800 ) ; if ( index != 0 ) { struct _B1{ unsigned char cmd ; unsigned int val ; }; _B1 b1 ; b1.cmd = ( index - 1 ) ; b1.val = htonl( nrand ) ; write_block( buf, 0x11, (unsigned char*)&b1 , sizeof(_B1) ) ; } else { write_byte( buf, 0x11, 0 ) ; } if ( nrand % 2 == 0 ) { struct _B2{ unsigned char type; unsigned int val ; unsigned char dir ; }; _B2 b2 ; b2.type = (( index + 1 ) % 5 ) ; b2.val = htonl( index ) ; b2.dir = ( index%2 == 0 ) ; write_block( buf, 0x12, (unsigned char*)&b2, sizeof(_B2) ) ; } if ( nrand % 3 == 0 ) { struct _B3{ unsigned int id ; unsigned short time ; unsigned char result ; }; _B3 b3 ; b3.id = htonl( index ) ; b3.time = htons( nrand % 100 ) ; b3.result = ( index % 2 == 0 ) ; write_block( buf , 0x13, (unsigned char*)&b3, sizeof(_B3) ) ; } switch( index ) { case 0: write_word( buf, 0x20, nrand ) ; write_word( buf, 0x21, nrand % 100 ) ; write_word( buf, 0x22, nrand % 1000 ) ; write_word( buf, 0x23, nrand % 80 ) ; case 1: write_dword( buf, 0x24, nrand % 157887 ) ; write_dword( buf, 0x25, nrand % 233555 ) ; write_dword( buf, 0x26, nrand % 200 ) ; write_dword( buf, 0x40, nrand % 3000 ) ; case 2: write_word( buf, 0x41, nrand % 130 ) ; write_word( buf, 0x42, nrand % 120 ) ; write_word( buf, 0x43, nrand % 200 ) ; write_word( buf, 0x44, nrand % 300 ) ; case 3: write_word( buf, 0x45, nrand % 150 ) ; write_word( buf, 0x46, nrand % 100 ) ; case 4: write_word( buf, 0x47, nrand % 150 ) ; write_word( buf, 0x48, nrand % 200 ) ; break ; } } // 长度为消息内容的长度去掉头和尾 unsigned short mlen = (buf.getLength()-sizeof(GBheader)) & 0x03FF ; buf.fillInt16( mlen, 3 ) ; GBFooter footer ; buf.writeBlock( &footer, sizeof(footer) ) ; if ( Send5BData( p->fd_, buf.getBuffer(), buf.getLength() ) ) { p->gps_pos_ = pos ; return true ; } p->car_state_ = OFF_LINE ; // 发送位置包 return false ; }
// 登陆服务器 bool CVechileMgr::LoginServer( _stVechile *pUser ) { if ( pUser->fd_ ) { CloseSocket( pUser->fd_ ) ; } if ( pUser->ufd_ ) { CloseSocket( pUser->ufd_ ) ; } // 如果连接模式为TCP if ( _connect_mode & TCP_MODE ) { pUser->fd_ = _tcp_handle.connect_nonb( _server_ip.c_str() , _server_port , 10 ) ; if ( pUser->fd_ == NULL ) { return false ; } if ( _connect_mode & UDP_MODE ) { // 如果为UDP和TCP混合模式 pUser->ufd_ = _udp_handle.connect_nonb( _server_ip.c_str() , _server_port , 10 ) ; if ( pUser->ufd_ ) { _bench.IncBench( BENCH_CONNECT, 1 ) ; } } }else if( _connect_mode & UDP_MODE ){ // 如果为UDP模式 pUser->fd_ = _udp_handle.connect_nonb( _server_ip.c_str() , _server_port , 10 ) ; } if( pUser->fd_ != NULL ) { _bench.IncBench( BENCH_CONNECT, 1 ) ; // 登陆将SOCK的数据放到里机 pUser->fd_->_ptr = pUser ; unsigned short len = sizeof(TermRegisterHeader) + sizeof(GBFooter) + strlen(pUser->carnum_); TermRegisterHeader req ; BuildHeader( req.header, 0x0100 , (len-sizeof(GBFooter)-sizeof(GBheader)) , pUser ) ; req.carcolor = pUser->carcolor ; req.province_id = htons( pUser->proid ) ; req.city_id = htons( pUser->cityid ) ; safe_memncpy( (char*)req.corp_id , pUser->termid_ , sizeof(req.corp_id ) ) ; safe_memncpy( (char*)req.termtype, pUser->termtype, sizeof(req.termtype ) ) ; safe_memncpy( (char*)req.termid , pUser->termid_ , sizeof(req.termid ) ) ; int offset = 0 ; char *buf = new char[len+1] ; memcpy( buf, &req, sizeof(req) ) ; offset += sizeof(req) ; memcpy( buf+offset, pUser->carnum_, strlen(pUser->carnum_) ) ; offset += strlen(pUser->carnum_) ; GBFooter footer ; memcpy( buf + offset, &footer, sizeof(footer) ) ; if ( Send5BData( pUser->fd_, buf, len ) ) { OUT_CONN( NULL , 0 , "VMGR" , "connect success,send register message, phone num: %s" , BCDtostr(pUser->car_id_).c_str() ) ; } else { OUT_ERROR( NULL, 0 , "VMGR" , "connect success,send register message, phone num: %s" , BCDtostr(pUser->car_id_).c_str() ) ; } delete [] buf ; } return ( pUser->fd_ != NULL ) ; }
int Response::Build() { if( CODE == 0 ) { logger_<<WARNING<<"The response code should be set!"<<endl; CODE = 500; meta_->KEEP_ALIVE = false; } if( TYPE == 0 ) { logger_<<WARNING<<"The type should be set!"<<endl; CODE = 500; meta_->KEEP_ALIVE = false; } if(NULL == data_) { logger_<<WARNING<<"The response data should be set!"<<endl; CODE = 500; meta_->KEEP_ALIVE = false; } else { BuildHeader(); } // 填充header string reason = Mapper::GetInstance()->GetReason(CODE); string protocol = "HTTP/1.1"; string header_str = protocol + " " + reason + "\r\n"; for(unordered_map<string, string>::iterator iter = header_.begin(); iter != header_.end(); ++ iter) { header_str += (*iter).first + ": " + (*iter).second + "\r\n"; } header_str += "\r\n"; memcpy(buffer_, header_str.c_str(), header_str.length()); buffer_length_ += header_str.length(); if( CODE == 304 || CODE == 500 ) { return 0; } // 填充data if( TYPE == 1 ) { char content_length[20]; sprintf(content_length, "%lx\r\n", size_); memcpy(buffer_ + buffer_length_, content_length, strlen(content_length)); buffer_length_ += strlen(content_length); memcpy(buffer_ + buffer_length_, data_, size_); buffer_length_ += size_; char buffer_end[20] = "\r\n0\r\n\r\n"; memcpy(buffer_ + buffer_length_, buffer_end, strlen(buffer_end)); buffer_length_ += strlen(buffer_end); } else { memcpy(buffer_ + buffer_length_, data_, size_); buffer_length_ += size_; } return 0; }
// @brief: handles webclient // @param[in]: socket - socket that client is connected on // @param[in]: ip_addr - ip address of the client void WebHostEmulator::HandleClient(SOCKET* socket, const std::string ip_addr) { #ifdef __DEBUG static int ThreadCounter = 0; const int ThreadID = ThreadCounter++; printf("Thread %i started\n", ThreadID); #endif std::queue <std::string> RecvQueue; std::string Received, overflow; while (1) { // Recieve std::string RecvBuffer; RecvBuffer.resize(8192); int iResult = recv(*socket, &RecvBuffer[0], RecvBuffer.length(), 0); if (iResult <= 0) { #ifdef __DEBUG printf("Thread %i ended\n", ThreadID); #endif closesocket(*socket); delete socket; return; } RecvBuffer.resize(iResult); if (parseHTTP (RecvBuffer, Received, overflow) != 0) { continue; } #ifdef __DEBUG printf("Received Message:-----\n%s\nEnd Received-----\n\n", Received.c_str()); #endif // Send size_t found; std::string Body, ContentLength, ContentType, Header, Response; found = Received.find("GET"); if (found == 0) { size_t start = Received.find("/"); size_t end = Received.find(" ", start); ContentType = GetReq(std::string(Received, start, end - start), Body); Header = BuildHeader(Body, 200, ContentType, true); Response = Header + Body; iResult = send(*socket, Response.c_str(), Response.size(), 0); } found = Received.find("POST"); if (found == 0) { size_t start = Received.find("/"); size_t end = Received.find(" ", start); std::string Result = PostReq( std::string(Received, start, end - start), GetBody(Received), ip_addr ); ContentType = "text/html"; // This is a temp fix. Body = BuildResult(Result, std::string("result.html")); Header = BuildHeader(Body, 200, ContentType, false); Response = Header + Body; iResult = send(*socket, Response.c_str(), Response.size(), 0); } Received.clear(); } #ifdef __DEBUG printf("Thread %i ended\n", ThreadID); #endif closesocket(*socket); delete socket; return; }