void TcpThread::run(){

    tcpSocket=new QTcpSocket; //服务器连接上后与客户端通讯的子套接字
    if (!tcpSocket->setSocketDescriptor(socketDescriptor)) {
        emit error(tcpSocket->error());
        return;
    }

     connect(tcpSocket,SIGNAL(readyRead()),this,SLOT(getClientData()),Qt::DirectConnection);



 //   connect(time,SIGNAL(timeout()),this,SLOT(judge()),Qt::DirectConnection);//



    tcpSocket->waitForDisconnected();

      //   QTimer::singleShot(2000, this, SLOT(judge()));
        // connect(timer, SIGNAL(timeout()), this, SLOT(judge()),Qt::DirectConnection);


     //   exec();


}
Пример #2
0
/* virtual */ SysStatusUval
LinuxPTYServer::recvfrom(struct iovec *vec, uval veclen, uval flags,
			 char *addr, uval &addrLen, GenState &moreAvail, 
			 void *controlData, uval &controlDataLen,
			 __XHANDLE xhandle)
{
    addrLen = 0;

    controlDataLen = 0; /* setting to zero, since no control data */

    AutoLock<LockType> al(&_lock);
    ClientData *cd = getClientData(xhandle);
    SysStatusUval rc = 0;


    ProcessLinux::LinuxInfo info;
    ProcessID pid = XHandleTrans::GetOwnerProcessID(xhandle);
    rc = DREFGOBJ(TheProcessLinuxRef)->getInfoNativePid(pid, info);
    tassertMsg(_SUCCESS(rc),
	       "Couldn't get info about k42 process 0x%lx\n", pid);

    PTYTaskInfo ptyTI(info.pid, info.pgrp, info.session, info.tty,
		      info.pid == info.session);

    LinuxEnv sc(SysCall, ptyTI.t);
    rc = 0;
    for (uval i = 0; i<veclen; ++i) {
	int nr = ttydev_read(oli, (char*)vec[i].iov_base,
			     vec[i].iov_len, &availMask);
	if (nr < 0) {
	    if (rc>0) break;
	    if (nr==-EWOULDBLOCK) break;
	    rc = _SERROR(2495, 0, -nr);
	    break;
	}
	rc += nr;
    }
    availMask = ttydev_poll(oli);
    calcAvailable(moreAvail);
    cd->setAvail(moreAvail);
    return rc;
}