void Modem::readChar( int ) { uchar c; while ( read( fd, (void *) &c, 1 ) == 1 ) { if ( c == '\n' ) { buffer[ bufpos ] = 0; bufpos = 0; emit gotLine( (const char *) buffer ); break; } else if ( ( bufpos < 1000 ) && ( c != '\r' ) ) buffer[ bufpos++ ] = c; } }
void IrcLayer::ircConnect() { m_active=true; if (!m_ircServer->contact()) { //qDebug("We are connected! Joining..."); if(targetMode()==ChannelMode) { //qDebug() << "Joining " << m_target << __LINE__; ircJoin(target()); } } else { //qDebug("No we aren't"); infMsg(tr("Contacting IRC server...")); } connect(m_ircServer, SIGNAL(connected()), this, SLOT(ircLogon())); connect(m_ircServer, SIGNAL(gotLine(QByteArray)), this, SLOT(ircParse(QByteArray))); connect(m_ircServer, SIGNAL(disconnected()), this, SLOT(gotDisconnected())); }
//========================================= // clientReadWrite //----------------------------------------- void SSLClient::clientReadWrite ( void ) { FD_SET (mSocket,&readFDs); int width = mSocket + 1; while (1) { //struct timeval timeout; //timeout.tv_sec = 0; //timeout.tv_usec = 1000; select (width,&readFDs,0,0,0); char buf[2]; QString line; int len = 0; if (FD_ISSET (mSocket,&readFDs)) { do { int r = SSL_read (ssl,buf,1); switch (SSL_get_error(ssl,r)) { case SSL_ERROR_NONE: len=r; break; case SSL_ERROR_WANT_READ: continue; break; case SSL_ERROR_ZERO_RETURN: continue; break; case SSL_ERROR_SYSCALL: qerror ("SSL Error: Premature close"); break; default: continue; break; } if (buf[0] == '\n') { gotLine (line); } else { line.append(buf[0]); } } while (SSL_pending(ssl)); } } }