コード例 #1
0
bool PhSonyController::open(bool inThread)
{
	PHDEBUG << _comSuffix;
	foreach(QSerialPortInfo info, QSerialPortInfo::availablePorts())
	{
		QString name = info.portName();
		PHDEBUG << name;

		if(name.endsWith(_comSuffix)) {
			_serial.setPort(info);

			PHDEBUG << _comSuffix << "Opening " << name << _serial.parent();
			if( _serial.open(QSerialPort::ReadWrite)) {
				_serial.setBaudRate(QSerialPort::Baud38400);
				_serial.setDataBits(QSerialPort::Data8);
				_serial.setStopBits(QSerialPort::OneStop);
				_serial.setParity(QSerialPort::OddParity);

				if(inThread)
					this->start(QThread::HighPriority);
				else
					connect(&_serial, SIGNAL(readyRead()), this, SLOT(onData()));
				return true;
			}
		}
	}
コード例 #2
0
int SearchManager::run() {

	boost::scoped_array<uint8_t> buf(new uint8_t[BUFSIZE]);
	int len;

	while(true) {

		string remoteAddr;
		try {
			while( (len = socket->read(&buf[0], BUFSIZE, remoteAddr)) != 0) {
				onData(&buf[0], len, remoteAddr);
			}
		} catch(const SocketException& e) {
			dcdebug("SearchManager::run Error: %s\n", e.getError().c_str());
		}
		if(stop) {
			return 0;
		}

		try {
			socket->disconnect();
			socket->create(Socket::TYPE_UDP);
			socket->bind(port, SETTING(BIND_ADDRESS));
		} catch(const SocketException& e) {
			// Oops, fatal this time...
			dcdebug("SearchManager::run Stopped listening: %s\n", e.getError().c_str());
			return 1;
		}
	}

	return 0;
}
コード例 #3
0
QstProtocol::QstProtocol(QObject *parent)
    : QTcpSocket(parent)
    , tx_msg_id(1)
    , port(0)
    , onData_busy(false)
    , enable_reconnect(false)
    , reconnect_interval(10000)
    , last_data_received(false)
    , connection_valid(false)
    , debug_on(false)
    , m_auto_unpack(true)
{
    static int id1 = qRegisterMetaType<QstMessage>(); Q_UNUSED(id1);
    static int id2 = qRegisterMetaType<QstMessage*>(); Q_UNUSED(id2);
    static int id3 = qRegisterMetaType<const QstMessage*>(); Q_UNUSED(id3);

    unique_id = QString::number(++g_unique_id);
    if (debug_on) {
        qDebug() << QString("%1 QstProtocol::QstProtocol()").arg(uniqueId()).toLatin1();
    }
    cur_message = 0;
    rx_busy = false;

    QObject::connect( &connect_timer, SIGNAL(timeout()), this, SLOT(connectTimeout()), Qt::DirectConnection );

    QObject::connect( this,SIGNAL(connected()),this,SLOT(onSocketConnected()), Qt::DirectConnection );
    QObject::connect( this,SIGNAL(disconnected()),this,SLOT(onSocketClosed()), Qt::DirectConnection );
    QObject::connect( this,SIGNAL(readyRead()),this,SLOT(onData()), Qt::DirectConnection );

    // initialize. Any time is better than no time.
    rx_timer.start();
}
コード例 #4
0
ファイル: TcpClient.cpp プロジェクト: SourceCodeDude/mcproxy
void TcpClient::onRead(struct ev_loop *loop, CustomIO *watcher, int revents)
{
	char buffer[512];

	// Receive message from client socket
#ifdef WIN32
	int
#else
	ssize_t
#endif
	read = recv(FD_TO_HANDLE(watcher->io.fd), buffer, sizeof(buffer), 0);

	if (read < 0)
	{
		perror("read error");
		return;
	}
	else if (read == 0)
	{
		perror("peer is closing");
		// Stop and free watcher if client socket is closing
		ev_io_stop(loop, &watcher->io);
		return;
	}
	
	onData(buffer, read);
}
コード例 #5
0
ファイル: server.c プロジェクト: pqzhou2005/tests
int main(int argv,char **args)
{
	int ret,epfd,nfds,server_socket_fd,i,index;
	struct epoll_event events[256];
	int count;	

	server_socket_fd = server_start();	
	if(server_socket_fd<0)
	{
		return 0;
	}
	set_non_blocking(server_socket_fd);

	epfd = epoll_create(1024);
	set_non_blocking(epfd);
	epoll_add(epfd,server_socket_fd);

	struct http_request_r *r=NULL,*p=NULL;

        while(1)
        {
                nfds=epoll_wait(epfd,events,20,500);
                for(i=0;i<nfds;i++)
                {
                        if(events[i].data.fd==server_socket_fd)
                        {
				onAccept(epfd,events[i],&r);
			}
                        else if(events[i].events&EPOLLIN)
                        {
				onData(epfd,events[i],&r);
                        }
                }
        }
}
コード例 #6
0
void AndroidBluetooth::listen() {
    if(available()){//check if there's any data sent from the remote bluetooth shield
        recvChar = read();
        //      Serial.print(recvChar);
        if(message.length() < MESSAGE_LENGTH) {
            message.concat(recvChar);
        }
    } else if(message.length() > 0){
            if(message.indexOf("+BTSTATE:1") >= 0) {
                state = DISCONNECTED;
                if(onDisconnect) onDisconnect();
            } else if(message.indexOf("+BTSTATE:4") >= 0) {
                state = CONNECTED;
                if(onConnect) onConnect();
                String temp = "blpins:D";
                temp.concat(rxPin);
                temp.concat("&D");
                temp.concat(txPin);
                send(temp);
                temp = "";
            } else if(message.indexOf("+BTSTATE:3") >= 0) {
            
            } else if(message.indexOf("CONNECT:OK") >= 0) {
                
            } else if(message.indexOf("ERROR") >= 0) {
                
            } else if(message.indexOf("pRQST") >= 0) {
                //Get Type Analog vs Digital
                (message.charAt(5) == 'A') ? type = 1 : type = 0;
                //Get state HIGH vs LOW
                if(message.indexOf("false") >= 0) isHigh = 0;
                else isHigh = 1;
                //Get Pin Number
                char *buffer = {"h"};
                message.substring(6,8).toCharArray(buffer, 3);
                pin = atoi(buffer);
                //Send data to callback
                if(onPin) onPin(type, pin, isHigh);
                if(type == 0) {
                    Serial.print("Requested:");
                    Serial.print("Digital Pin ");
                    Serial.print(pin);
                    Serial.print(" to ");
                    if(isHigh) Serial.println("HIGH");
                    else Serial.println("LOW");
                }
                else {
                    send((String)analogRead(pin));
                    Serial.print("Analog Pin ");
                    Serial.print(pin);
                    Serial.print(" Read ");
                    Serial.println(analogRead(pin));
                }
                buffer = NULL;
            }
            else if (onData) onData(message);
            message = "";
    }
}
コード例 #7
0
ファイル: HttpClient.cpp プロジェクト: jimmy486/kuma
void HttpClient::startRequest(std::string& url)
{
    http_request_.setDataCallback([this] (uint8_t* data, uint32_t len) { onData(data, len); });
    http_request_.setWriteCallback([this] (int err) { onSend(err); });
    http_request_.setErrorCallback([this] (int err) { onClose(err); });
    http_request_.setHeaderCompleteCallback([this] { onHeaderComplete(); });
    http_request_.setResponseCompleteCallback([this] { onRequestComplete(); });
    http_request_.sendRequest("GET", url.c_str(), "HTTP/1.1");
}
コード例 #8
0
void IntEngine::init(QProcess *engine_proc)
{
    if(IntEngine_helper.isNull())
        IntEngine_helper = QSharedPointer<IntEngine>(new IntEngine);

    if(!engine)
    {
        engine = engine_proc;
        engine->connect(engine, SIGNAL(readyReadStandardOutput()),
                        &(*IntEngine_helper), SLOT(onData()));
    }
}
コード例 #9
0
int SearchManager::run() {
	boost::scoped_array<uint8_t> buf(new uint8_t[BUFSIZE]);
	int len;
	string remoteAddr;

	while(!stop) {
		try {
			if(!socket->wait(400, true, false).first) {
				continue;
			}

			if((len = socket->read(&buf[0], BUFSIZE, remoteAddr)) > 0) {
				string data(reinterpret_cast<char*>(&buf[0]), len);

				if(PluginManager::getInstance()->onUDP(false, remoteAddr, port, data))
					continue;

				onData(data, remoteAddr);
				continue;
			}

		} catch(const SocketException& e) {
			dcdebug("SearchManager::run Error: %s\n", e.getError().c_str());
		}

		bool failed = false;
		while(!stop) {
			try {
				socket->disconnect();
				port = socket->listen(Util::toString(CONNSETTING(UDP_PORT)));
				if(failed) {
					LogManager::getInstance()->message(_("Search enabled again"));
					failed = false;
				}
				break;
			} catch(const SocketException& e) {
				dcdebug("SearchManager::run Stopped listening: %s\n", e.getError().c_str());

				if(!failed) {
					LogManager::getInstance()->message(str(F_("Search disabled: %1%") % e.getError()));
					failed = true;
				}

				// Spin for 60 seconds
				for(auto i = 0; i < 60 && !stop; ++i) {
					Thread::sleep(1000);
				}
			}
		}
	}
	return 0;
}
コード例 #10
0
ファイル: SearchManager.cpp プロジェクト: Mezomish/leechcraft
int SearchManager::run() {
    boost::scoped_array<uint8_t> buf(new uint8_t[BUFSIZE]);
    int len;
    string remoteAddr;

    while(!stop) {
        try {
            while( true ) {
                // Patch from FlylinkDC++, see:
                // http://code.google.com/p/flylinkdc/source/detail?r=6132
                // http://bazaar.launchpad.net/~dcplusplus-team/dcplusplus/trunk/revision/2414
                // .
                // @todo: remove this workaround for http://bugs.winehq.org/show_bug.cgi?id=22291
                // if that's fixed by reverting to simpler while (read(...) > 0) {...} code.
                while (socket->wait(400, Socket::WAIT_READ) != Socket::WAIT_READ);
                if (stop || (len = socket->read(&buf[0], BUFSIZE, remoteAddr)) <= 0)
                    break;
                onData(&buf[0], len, remoteAddr);
            }
        } catch(const SocketException& e) {
            dcdebug("SearchManager::run Error: %s\n", e.getError().c_str());
        }

        bool failed = false;
        while(!stop) {
            try {
                socket->disconnect();
                socket->create(Socket::TYPE_UDP);
                socket->setBlocking(true);
                socket->bind(port, SETTING(BIND_ADDRESS));
                if(failed) {
                    LogManager::getInstance()->message(_("Search enabled again"));
                    failed = false;
                }
                break;
            } catch(const SocketException& e) {
                dcdebug("SearchManager::run Stopped listening: %s\n", e.getError().c_str());

                if(!failed) {
                    LogManager::getInstance()->message(str(F_("Search disabled: %1%") % e.getError()));
                    failed = true;
                }

                // Spin for 60 seconds
                for(int i = 0; i < 60 && !stop; ++i) {
                    Thread::sleep(1000);
                }
            }
        }
    }
    return 0;
}
コード例 #11
0
void
PipeWatcher::threadMain() {
	TRACE_POINT();
	{
		boost::unique_lock<boost::mutex> lock(startSyncher);
		while (!started) {
			startCond.wait(lock);
		}
	}

	UPDATE_TRACE_POINT();
	while (!this_thread::interruption_requested()) {
		char buf[1024 * 8];
		ssize_t ret;
		
		UPDATE_TRACE_POINT();
		ret = syscalls::read(fd, buf, sizeof(buf));
		if (ret == 0) {
			break;
		} else if (ret == -1) {
			UPDATE_TRACE_POINT();
			if (errno == ECONNRESET) {
				break;
			} else if (errno != EAGAIN) {
				int e = errno;
				P_WARN("Cannot read from process " << pid << " " << name <<
					": " << strerror(e) << " (errno=" << e << ")");
				break;
			}
		} else if (ret == 1 && buf[0] == '\n') {
			UPDATE_TRACE_POINT();
			printAppOutput(pid, name, "", 0);
		} else {
			UPDATE_TRACE_POINT();
			vector<StaticString> lines;
			ssize_t ret2 = ret;
			if (ret2 > 0 && buf[ret2 - 1] == '\n') {
				ret2--;
			}
			split(StaticString(buf, ret2), '\n', lines);
			foreach (const StaticString line, lines) {
				printAppOutput(pid, name, line.data(), line.size());
			}
		}

		if (onData != NULL) {
			onData(buf, ret);
		}
	}
コード例 #12
0
ファイル: MessageReader.cpp プロジェクト: bbcarchdev/qpid-cpp
//data, amqp-value
void MessageReader::onBinary(const CharSequence& bytes, const Descriptor* descriptor)
{
    if (delegate) {
        delegate->onBinary(bytes, descriptor);
    } else {
        if (!descriptor) {
            QPID_LOG(warning, "Expected described type but got binary value with no descriptor.");
        } else if (descriptor->match(DATA_SYMBOL, DATA_CODE)) {
            onData(bytes);
        } else if (descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) {
            onAmqpValue(bytes, qpid::amqp::typecodes::BINARY_NAME);
        } else {
            QPID_LOG(warning, "Unexpected binary value with descriptor: " << *descriptor);
        }
    }

}
コード例 #13
0
ファイル: FirehoseModel.cpp プロジェクト: RJ/lastfm-desktop
void
FirehoseModel::reconnect()
{
    if (m_nozzle.isEmpty()) return;

    // using WsAccessManager stopped after the HEADERS were returned
    // for some reason. We block signals to prevent recursively calling this 
    // function
    if (m_socket) { 
        disconnect( m_socket, 0, this, 0 ); // don't call onFinished()
        m_socket->deleteLater(); //safer, we had a crash
    }
    m_socket = new QTcpSocket( this );
    connect( m_socket, SIGNAL(connected()), SLOT(onConnect()) );
    connect( m_socket, SIGNAL(readyRead()), SLOT(onData()) );
    connect( m_socket, SIGNAL(disconnected()), SLOT(onFinished()) );
    m_socket->connectToHost( "firehose.last.fm", 80 );
}
コード例 #14
0
ファイル: JSClient.cpp プロジェクト: jiephe/testForSucess
int CJSClient::OnRead(SOCKET fd)
{
	u_long avail = 0;
	if ( (ioctlsocket(m_fd, FIONREAD, &avail) == SOCKET_ERROR) || (avail == 0) )
	{
		m_bRunning = false;

		closesocket(m_fd);

		return 0;
	}

	char recvbuf[MAX_SEND_RCV_LEN] = {0};

	m_buffer.clear();

	for (;;)
	{
		int nRecvLen = recv(fd, recvbuf, sizeof(recvbuf), 0);
		if (nRecvLen <= 0)
		{
			break;
		}

		for (int i = 0; i < nRecvLen; ++i)
		{
			m_buffer.push_back(recvbuf[i]);
		}

		memset(recvbuf, 0x0, sizeof(recvbuf));
	}
	
	if (!m_buffer.empty())
	{
		onData();
	}

	return 0;
}
コード例 #15
0
bool WebSocket::getFrame() {
    byte bite;
    
    // Get opcode
    bite = client.read();
        
    frame.opcode = bite & 0xf; // Opcode
    frame.isFinal = bite & 0x80; // Final frame?
    // Determine length (only accept <= 64 for now)
    bite = client.read();
    frame.length = bite & 0x7f; // Length of payload
    if (frame.length > 64) {
        #ifdef DEBUG
            Serial.print("Too big frame to handle. Length: ");
            Serial.println(frame.length);
        #endif
        client.write((uint8_t) 0x08);
        client.write((uint8_t) 0x02);
        client.write((uint8_t) 0x03);
        client.write((uint8_t) 0xf1);
        return false;
    }
    // Client should always send mask, but check just to be sure
    frame.isMasked = bite & 0x80;
    if (frame.isMasked) {
        frame.mask[0] = client.read();
        frame.mask[1] = client.read();
        frame.mask[2] = client.read();
        frame.mask[3] = client.read();
    }
    
    // Get message bytes and unmask them if necessary
    for (int i = 0; i < frame.length; i++) {
        if (frame.isMasked) {
            frame.data[i] = client.read() ^ frame.mask[i % 4];
        } else {
            frame.data[i] = client.read();
        }
    }
    
    //
    // Frame complete!
    //
    
    if (!frame.isFinal) {
        // We don't handle fragments! Close and disconnect.
        #ifdef DEBUG
            Serial.println("Non-final frame, doesn't handle that.");
        #endif
        client.print((uint8_t) 0x08);
        client.write((uint8_t) 0x02);
        client.write((uint8_t) 0x03);
        client.write((uint8_t) 0xf1);
        return false;
    }

    switch (frame.opcode) {
        case 0x01: // Txt frame
            // Call the user provided function
            if (onData)
                onData(*this, frame.data, frame.length);
            break;
            
        case 0x08:
            // Close frame. Answer with close and terminate tcp connection
            // TODO: Receive all bytes the client might send before closing? No?
            #ifdef DEBUG
                Serial.println("Close frame received. Closing in answer.");
            #endif
            client.write((uint8_t) 0x08);
            return false;
            break;
            
        default:
            // Unexpected. Ignore. Probably should blow up entire universe here, but who cares.
    		#ifdef DEBUG
        		Serial.println("Unhandled frame ignored.");
    		#endif
			return false;
            break;
    }
    return true;
}
コード例 #16
0
ファイル: main.c プロジェクト: xiaokaisun90/Projects
void rx_task ()
{
	uint8_t pos,len,i,version;
	int8_t rssi;
  uint8_t *local_rx_buf;
  int16_t recipient,sender,dataseq;
	char type;
  if(log_g) printf ("log:rx_task PID=%d\r\n", nrk_get_pid ());
  // init bmac on channel 15 
  bmac_init (15);

  bmac_rx_pkt_set_buffer (rx_buf, RF_MAX_PAYLOAD_SIZE);

  while (1) {
    // Wait until an RX packet is received
    bmac_wait_until_rx_pkt ();
    // Get the RX packet 
    nrk_led_set (ORANGE_LED);
    local_rx_buf = bmac_rx_pkt_get (&len, &rssi);
    //if(log_g) printf ("log:Packet recv\n");
    //if(log_g) printf ("log:");
    //for (i = 0; i < len; i++) {
    //  if(log_g) printf ("%c", rx_buf[i]);
		//}
    //if(log_g) printf ("\n");

		pos = 0; 
		recipient = get_next_int(local_rx_buf,&pos,len); 
		pos+=1;
		sender = get_next_int(local_rx_buf,&pos,len);
		pos+=1; 
		type = local_rx_buf[pos];
		pos+=2;

		if((recipient != 0 && recipient != MAC_ADDR) || sender == MAC_ADDR) {

			if(log_g) printf("log:Ignore\r\n");

		} else if(recipient == 0 && type == 'S') {

			version =get_next_int(local_rx_buf,&pos,len);
			on_discover_pkt(sender, version);
 
		} else if (recipient == 0 && type == 'B') {

			onBasketBallPkt();
		
		}	else if (type == 'C') {

			version =get_next_int(local_rx_buf,&pos,len);
			onConnectionReq(sender,version);

		} else if(type == 'D' ) {

			dataseq = get_next_int(local_rx_buf,&pos,len);	
			onData(sender,dataseq,local_rx_buf,len);

		}	else if(type == 'A') {

			dataseq = get_next_int(local_rx_buf,&pos,len);	
			onAck(sender, dataseq);

		} else if(type == 'M') {
			onContactShare(local_rx_buf,len); 
		}else {

			if(log_g) printf("log:Invalid MSG\r\n");

		}
    
		// Release the RX buffer so future packets can arrive 
    memset(local_rx_buf,0,len+1);
    bmac_rx_pkt_release ();
  	nrk_led_clr(ORANGE_LED);
		nrk_wait_until_next_period();
	}
}
コード例 #17
0
ファイル: composer.cpp プロジェクト: qhwa/Rythem
Composer::Composer(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Composer){
    ui->setupUi(this);
    socket = new QTcpSocket();
    //socket->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,"127.0.0.1",8999));
    connect(socket,SIGNAL(connected()),SLOT(onConnected()));
    connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),SLOT(onError(QAbstractSocket::SocketError)));
    connect(socket,SIGNAL(aboutToClose()),SLOT(onClose()));
    connect(socket,SIGNAL(readyRead()),SLOT(onData()));

    connect(ui->connectbtn,SIGNAL(clicked()),SLOT(onConnectBtnClick()));
    connect(ui->sendbtn,SIGNAL(clicked()),SLOT(onSendBtnClick()));
    connect(ui->disconnectbtn,SIGNAL(clicked()),SLOT(onDisConnectBtnClick()));

    setAcceptDrops(true);

    ui->requestsComboBox->clear();

    QStringList requestStr;
    requestStr<<"w.l.qq.com"<<"80"<<
        "GET /lview?type=text&callback=auto_gen_1&loc=QQ_FC_RX_text1,QQ_FC_RX_text2,QQ_FC_RX_text3,QQ_FC_RX_text4,QQ_FC_RX_text5,QQ_FC_DZ_text1,QQ_FC_DZ_text2,QQ_FC_DZ_text3,QQ_FC_DZ_text4,QQ_FC_DZ_text5,QQ_FC_XP_text1,QQ_FC_XP_text2,QQ_FC_XP_text3,QQ_FC_XP_text4,QQ_FC_XP_text5,QQ_FC_ESF_text1,QQ_FC_ESF_text2,QQ_FC_ESF_text3,QQ_FC_ESF_text4,QQ_FC_ESF_text5,QQ_SX_ZS_Test1,QQ_SX_ZS_Test2,QQ_SX_ZS_Test3,QQ_SX_ZS_Test4,QQ_SX_ZS_Test5,QQ_SX_ZS_Test6,QQ_SX_ZS_Test7,QQ_SX_ZS_Test8,QQ_SX_ZS_Test9,QQ_SX_ZS_Test10,QQ_SX_LX_Test1,QQ_SX_LX_Test2,QQ_SX_LX_Test3,QQ_SX_LX_Test4,QQ_SX_LX_Test5,QQ_SX_LX_Test6,QQ_SX_LX_Test7,QQ_SX_LX_Test8,QQ_SX_LX_Test9,QQ_SX_LX_Test10&k=&t=%E8%85%BE%E8%AE%AF%E9%A6%96%E9%A1%B5&r=&s= HTTP/1.1"
        "\nHost: w.l.qq.com"
        "\nConnection: keep-alive"
        "\nAccept-Encoding: identity;q=1, *;q=0"
        "\nUser-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11"
        "\nAccept: */*"
        "\nReferer: http://im.qq.com/macqq/index.shtml"
        "\nAccept-Language: zh-CN,zh;q=0.8"
        "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
        "\nCookie: pgv_r_cookie=116156043288; sd_machines=-1|-1|-1|-1; comment_uin=164473028 %u0069%u0070%u0074%u0074%u006f%u006e; comment_skey=e7eadd2dda7ad02007b2aa2da36d34a7+iptton; old_friend=true; lv_irt_id=fe103783d2a200ef99be838e606bae5d; pvid=8739289251; mbCardUserNotLoginTips=1; pt2gguin=o0164473028; ptisp=ctc; show_id=; o_cookie=164473028; verifysession=h005f594834a73e2d5de281414f85629403925acc6e89b25a779dcb0a60d2147ed189c5a866140b5cc7; pgv_pvid=o_cookie=164473028; pgv_info=ssid=s9100271653&pgvReferrer="
        "\nRange: bytes=48-6116217"
        "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();

    requestStr<<"w.qq.com"<<"80"<<
                "GET /css/webmini_main.css HTTP/1.1"
                "\nHost: w.qq.com"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();

    requestStr<<"www.anjiala.com"<<"80"<<
                "GET /design/showview/2012-01-30/21393.html HTTP/1.1"
                "\nHost: www.anjiala.com"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();



    requestStr<<"trace.qq.com"<<"80"<<
                "GET /collect?pj=1990&dm=w.qq.com&url=/&arg=&rdm=&rurl=&rarg=&icache=-&uv=&nu=&ol=&loc=http%3A//w.qq.com/&column=&subject=&nrnd=164473028&rnd=852 HTTP/1.1"
                "\nHost: trace.qq.com"
                "\nProxy-Connection: keep-alive"
                "\nCache-Control: no-cache"
                "\nPragma: no-cache"
                "\nUser-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11"
                "\nAccept: */*"
                "\nReferer: http://w.qq.com/"
                "\nAccept-Encoding: gzip,deflate,sdch"
                "\nAccept-Language: zh-CN,zh;q=0.8"
                "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
                "\nCookie: pgv_r_cookie=116156043288; sd_machines=-1|-1|-1|-1; comment_uin=164473028 %u0069%u0070%u0074%u0074%u006f%u006e; comment_skey=e7eadd2dda7ad02007b2aa2da36d34a7+iptton; old_friend=true; lv_irt_id=fe103783d2a200ef99be838e606bae5d; pvid=8739289251; pt2gguin=o0164473028; qv_swfrfh=news.qq.com; qv_swfrfc=v2; verifysession=h008080f4865e1b20be8cba15fcb6b9a12b76209b5fe0c5e0355f92fe120c004d13ec81fb98ec036d86; pgv_pvid=o_cookie=164473028; pgv_info=ssid=s9694936942&pgvReferrer=; o_cookie=164473028"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();

    requestStr<<"qt.gtimg.cn"<<"80"<<
                "GET /0.7963608948048204&q=s_sh000001 HTTP/1.1"
                "\nHost: qt.gtimg.cn"
                "\nProxy-Connection: keep-alive"
                "\nUser-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
                "\nAccept: */*"
                "\nReferer: http://www.qq.com/"
                "\nAccept-Encoding: gzip,deflate,sdch"
                "\nAccept-Language: zh-CN,zh;q=0.8"
                "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();


    requestStr<<"bbs.anjiala.com"<<"80"<<
                "GET /member.php?mod=loginstatus HTTP/1.1"
                "\nHost: bbs.anjiala.com"
                "\nConnection: keep-alive"
                "\nUser-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
                "\nAccept: */*"
                "\nReferer: http://www.anjiala.com/design/showview/2012-01-30/21393.html"
                "\nAccept-Encoding: gzip,deflate,sdch"
                "\nAccept-Language: zh-CN,zh;q=0.8"
                "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
                "\nCookie: gQHG_a52f_lastvisit=1329015447; gQHG_a52f_sid=G80s6O; gQHG_a52f_lastact=1329024158%09member.php%09loginstatus"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();




    connect(ui->requestsComboBox,SIGNAL(currentIndexChanged(int)),SLOT(onRequestChanged(int)));


    ui->connectbtn->setDisabled(false);
    ui->sendbtn->setDisabled(true);
    ui->disconnectbtn->setDisabled(true);

    //connectToHost();
}