Example #1
0
HttpServer::HttpServer( QAbstractSocket * parent )
            : Protocol( parent, defaultTimeout ), state( ReadingHeader )
{
#ifdef DEBUG_XMLRPC
      qDebug() << this << "HttpServer():" << parent;
#endif

    connect( socket, SIGNAL( readyRead() ), this,  SLOT( slotReadyRead() ) );
    connect( socket, SIGNAL( bytesWritten(qint64) ), this, SLOT( slotBytesWritten(qint64) ) );
#ifndef QT_NO_OPENSSL
    if ( socket->inherits( "QSslSocket" ) )
        {
            QSslSocket *sslServer = qobject_cast<QSslSocket *>( socket );
            sslServer->startServerEncryption();
        }
    else
        {
            if ( socket->bytesAvailable() > 0 )
                {
                    slotReadyRead();
                }
        }
#else
    if ( socket->bytesAvailable() > 0 )
        {
            slotReadyRead();
        }
#endif
}
void CClientComWorker::run()
{
	MYLOG4CPP_DEBUG<<"CClientComWorker::run() begin";

	{
		QMutexLocker lock(&m_mutex_SocketW);
		m_pSocketHandle = new QTcpSocket();
		m_pSocketInfo = new CSocketInfo();
	}
	//
	QObject::connect(m_pSocketHandle, SIGNAL(connected()), this, SLOT(slotConnected()), Qt::AutoConnection);
	QObject::connect(m_pSocketHandle, SIGNAL(disconnected()), this, SLOT(slotDisconnected()), Qt::AutoConnection);
	QObject::connect(m_pSocketHandle, SIGNAL(readyRead()), this, SLOT(slotReadyRead()), Qt::AutoConnection);//Qt::AutoConnection Qt::BlockingQueuedConnection
	QObject::connect(m_pSocketHandle, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)), Qt::AutoConnection);

	m_WorkerState = WORK_STATE_BEGIN;
	m_WorkerState = WORK_STATE_WORKING;

	//slotConnectToServer();
	MYLOG4CPP_DEBUG<<" "<<"m_strID="<<m_pSocketInfo->m_strID
		<<" "<<"class:"<<" "<<"CClientComWorker"
		<<" "<<"fun:"<<" "<<"run"
		<<" "<<"emit signalDisconnected()"
		<<" "<<"param:"<<" "<<"m_nHandle="<<m_nHandle;

	emit signalDisconnected(m_nHandle);

	MYLOG4CPP_DEBUG<<"CClientComWorker::run() exec() begin";

	//QThread::exec() waits until QThread::exit() called
	exec();

	MYLOG4CPP_DEBUG<<"CClientComWorker::run() exec() end";


	//
	QObject::disconnect(m_pSocketHandle, SIGNAL(connected()), this, SLOT(slotConnected()));
	QObject::disconnect(m_pSocketHandle, SIGNAL(disconnected()), this, SLOT(slotDisconnected()));
	QObject::disconnect(m_pSocketHandle, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
	QObject::disconnect(m_pSocketHandle, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)));

	{
		QMutexLocker lock(&m_mutex_SocketW);
		if (NULL != m_pSocketHandle)
		{
			//m_pSocketHandle->waitForDisconnected();
			m_pSocketHandle->close();
			delete m_pSocketHandle;
			m_pSocketHandle = NULL;
		}
		if (NULL != m_pSocketInfo)
		{
			delete m_pSocketInfo;
			m_pSocketInfo = NULL;
		}
	}
	m_WorkerState = WORK_STATE_END;
	MYLOG4CPP_DEBUG<<"CClientComWorker::run() end";
}
Example #3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiaSocketServer::handleClientConnection(QTcpSocket* clientToHandle)
{
    CVF_ASSERT(clientToHandle != NULL);
    CVF_ASSERT(m_currentClient == NULL);
    m_currentClient = clientToHandle;

    // Initialize state varianbles
    m_currentCommandSize = 0;
    m_scalarResultsToAdd = NULL;

    m_timeStepCountToRead = 0;
    m_bytesPerTimeStepToRead = 0;
    m_currentTimeStepToRead = 0;
    m_currentReservoir = NULL;
    m_currentScalarIndex = cvf::UNDEFINED_SIZE_T;
    m_currentPropertyName = "";

    connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected()));
    m_readState = ReadingCommand;

    if (m_currentClient->bytesAvailable())
    {
        this->readCommandFromOctave();
    }

    connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
}
Example #4
0
Client::Client(const QString &host, int port, QWidget *parent) : QWidget(parent), blockSize(0)
{
    socket = new QTcpSocket(this);

    socket->connectToHost(host, port);
    connect(socket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(socket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError)));

    info = new QTextEdit;
    input = new QLineEdit;

    info->setReadOnly(true);

    QPushButton* button = new QPushButton("&Send");
    connect(button, SIGNAL(clicked()), SLOT(slotSendToServer()));
    connect(input, SIGNAL(returnPressed()), SLOT(slotSendToServer()));

    QVBoxLayout* layout = new QVBoxLayout;
    layout->addWidget(new QLabel("<h1>Client</h1>"));
    layout->addWidget(info);
    layout->addWidget(input);
    layout->addWidget(button);

    setLayout(layout);
}
MyClient::MyClient(const QString & hoststr, int port, QWidget * pwgt)
  : QWidget(pwgt), nextBlockSize(0) {
  tcpSocket = new QTcpSocket(this);
  // установить связь с сервером
  tcpSocket->connectToHost(hoststr, port);
  // сокет отправляет сигнал connected() как только будет создано соединение
  connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
  // сокет отправляет сигнал readyRead() при готовности предоставить данные для чтения
  connect(tcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
  // в случае возникновения ошибки сокет отправляет сигнал error
  connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
          this, SLOT(slotError(QAbstractSocket::SocketError)));
  textInfo = new QTextEdit;
  textInput = new QLineEdit;
  textInfo->setReadOnly(true);

  QPushButton * cmd = new QPushButton("&Send");
  connect(cmd, SIGNAL(clicked()), SLOT(slotSendToServer()));
  connect(textInput, SIGNAL(returnPressed()), this, SLOT(slotSendToServer()));

  QVBoxLayout * mainLayout = new QVBoxLayout;
  mainLayout->addWidget(new QLabel("<H1>Client</H1>"));
  mainLayout->addWidget(textInfo);
  mainLayout->addWidget(textInput);
  mainLayout->addWidget(cmd);
  setLayout(mainLayout);
}
Example #6
0
void QXmppSocksClient::slotReadyRead()
{
    if (m_step == ConnectState)
    {
        m_step++;

        // receive connect to server response
        QByteArray buffer = readAll();
        if (buffer.size() != 2 || buffer.at(0) != SocksVersion || buffer.at(1) != NoAuthentication)
        {
            qWarning("QXmppSocksClient received an invalid response during handshake");
            close();
            return;
        }

        // send CONNECT command
        buffer.resize(3);
        buffer[0] = SocksVersion;
        buffer[1] = ConnectCommand;
        buffer[2] = 0x00; // reserved
        buffer.append(encodeHostAndPort(
            DomainName,
            m_hostName.toLatin1(),
            m_hostPort));
        write(buffer);

    } else if (m_step == CommandState) {
        m_step++;

        // disconnect from signal
        disconnect(this, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));

        // receive CONNECT response
        QByteArray buffer = readAll();
        if (buffer.size() < 6 ||
            buffer.at(0) != SocksVersion ||
            buffer.at(1) != Succeeded ||
            buffer.at(2) != 0)
        {
            qWarning("QXmppSocksClient received an invalid response to CONNECT command");
            close();
            return;
        }

        // parse host
        quint8 hostType;
        QByteArray hostName;
        quint16 hostPort;
        if (!parseHostAndPort(buffer.mid(3), hostType, hostName, hostPort))
        {
            qWarning("QXmppSocksClient could not parse type/host/port");
            close();
            return;
        }
        // FIXME : what do we do with the resulting name / port?

        // notify of connection
        emit ready();
    }
}
Example #7
0
void BlFile::sync() {
  BL_FUNC_DEBUG  

//  if (!exists() {
  
      QFileInfo fileInfo(m_file);
      QString filename(fileInfo.fileName());
      
      QString user = g_confpr->value(CONF_LOGIN_USER);
      QString dbname = g_confpr->value(CONF_DBNAME);
    #ifdef Q_OS_WIN32
      QString platform = "MS_WIN";
    #else
      QString platform = "LINUX";
    #endif
      
      QString url = "http://www.bulmages.com/bulmaincloud/"+platform+"/"+user+"/"+dbname+"/"+filename;
      fprintf(stderr, "Iniciando descarga %s\n", url.toLatin1().constData());
      
      manager = new QNetworkAccessManager(this);
      QNetworkRequest request;
      request.setUrl(QUrl(url));
      request.setRawHeader("User-Agent", "BgBrowser 1.0");
    
      QNetworkReply *reply = manager->get(request);
      connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
      connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));

      connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
	    this, SLOT(slotError(QNetworkReply::NetworkError)));
      connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
	    this, SLOT(slotSslErrors(QList<QSslError>)));
      connect(manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));

      while (reply->isRunning()) {
	QApplication::processEvents();
      } // end while
 
//  }// end if
 
      url = "http://www.bulmages.com/bulmaincloud/ALL/"+user+"/"+dbname+"/"+filename;
      fprintf(stderr, "Iniciando descarga %s\n", url.toLatin1().constData());
      request.setUrl(QUrl(url));
      reply = manager->get(request);
      while (reply->isRunning()) {
	QApplication::processEvents();
      } // end while
      if (reply->error() == QNetworkReply::NoError) {
	return;
      } // end if

      url = "http://www.bulmages.com/bulmaincloud/ALL/ALL/"+filename;
      fprintf(stderr, "Iniciando descarga %s\n", url.toLatin1().constData());
      request.setUrl(QUrl(url));
      reply = manager->get(request);
      while (reply->isRunning()) {
	QApplication::processEvents();
      } // end while
    
}
Example #8
0
Client::Client(const QString &strHost, int port, QWidget *parent) :
    QWidget(parent),
    nextBlockSize(0)
{
    mySocket = new QTcpSocket();

    mySocket->connectToHost(strHost, port);
    connect(mySocket, SIGNAL(connected()), this, SLOT(slotConnected()));
    connect(mySocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    connect(mySocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(slotError(QAbstractSocket::SocketError)));

    txtInfo = new QTextEdit();
    txtInput = new QLineEdit();

    txtInfo->setReadOnly(true);
    QPushButton *send = new QPushButton("&Send");

    connect(send, SIGNAL(clicked()), this, SLOT(slotSendToServer()));
    connect(txtInput, SIGNAL(returnPressed()), this, SLOT(slotSendToServer()));

    QVBoxLayout *form = new QVBoxLayout(this);
    form->addWidget(new QLabel("<H1>Client</H1>"));
    form->addWidget(txtInfo);
    form->addWidget(txtInput);
    form->addWidget(send);
}
Example #9
0
/*! \~russian
 * \brief Метод предназначен для соединения внутренних сигналов и слотов класса.
 */
void TcpClient::connectSignalsAndSlots()
{
    connect(&_socket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(&_socket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this,       SLOT(slotError(QAbstractSocket::SocketError))
            );
}
void TcpClient::disconnectHost()
{
    m_pTcpSocket->disconnectFromHost();
    disconnect(m_pTcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
    disconnect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    disconnect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
               this,         SLOT(slotError(QAbstractSocket::SocketError)));
    emit connected(m_connectionState = -1);
}
Example #11
0
QXmppSocksClient::QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent)
    : QTcpSocket(parent),
    m_proxyHost(proxyHost),
    m_proxyPort(proxyPort),
    m_step(ConnectState)
{
    connect(this, SIGNAL(connected()), this, SLOT(slotConnected()));
    connect(this, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
}
Example #12
0
Network::Network():
    m_blockSize(0),
    m_data("")
{
    m_sslSocket = new QSslSocket();
    m_sslSocket->setPeerVerifyMode(QSslSocket::VerifyNone);
    m_sslSocket->setProtocol(QSsl::TlsV1_0);
    connect(m_sslSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
    connect(m_sslSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
}
Example #13
0
// Prevention against concurrent requests without waiting for a (delayed) reply,
// but untestable with QNAM on the client side, since it doesn't do that.
void KDSoapServerSocket::setSocketEnabled(bool enabled)
{
    if (m_socketEnabled == enabled)
        return;

    m_socketEnabled = enabled;
    if (enabled) {
        slotReadyRead();
    }
}
Example #14
0
/// private function
   void CServerManager::connectToServer(const std::string& serverIP,
      const unsigned int m_serverPort)
   {
      m_tcpSocket = new QTcpSocket(this);

      m_tcpSocket->connectToHost(QString(serverIP.c_str()), m_serverPort);
      connect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
      connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
      connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
         this,SLOT(slotError(QAbstractSocket::SocketError)));      
   }
Example #15
0
client::client(QString host)
{
    m_pTcpSocket = new QTcpSocket(this);
    m_pTcpSocket->connectToHost(host, nPort);

    connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    connect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError()));

    game = NULL;
}
Example #16
0
KontomierzReply::KontomierzReply(const  char * a)
{
 QNetworkAccessManager *manager = new QNetworkAccessManager(this);
 
 QNetworkRequest *request = new QNetworkRequest;
 connect(manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
            SLOT(provideAuthenication(QNetworkReply*,QAuthenticator*)));

 request->setUrl(QUrl(a));
 reply = manager->get(*request);
  connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
  
}
Example #17
0
void GameClient::connectToServer(const QString &server)
{
    serverAddr = server;
    int socketNumber = 2327;

    tcpSocket = new QTcpSocket(this);
    tcpSocket->connectToHost(serverAddr, socketNumber);

    connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(tcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            SLOT(slotError(QAbstractSocket::SocketError)));
}
Example #18
0
void MainWindow::connectToHost()
{
    if (ui->le_connect->text() != "...")
    {
    m_pTcpSocket->connectToHost(ui->le_connect->text(), nPort);
    connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(m_pTcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    }
    else
    {
        ui->statusBar->showMessage("Enter Server IP Adress!");
    }
}
Example #19
0
void PictureDownloader::getPicture(QString addr)
{
    QUrl url(addr);

    QNetworkRequest request(url);

    m_buffer.clear();

    m_networkReply = m_network->get(request);

    connect(m_networkReply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    connect(m_networkReply, SIGNAL(finished()), this, SLOT(slotFinished()));
    connect(m_networkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotNetworkReplyError(QNetworkReply::NetworkError)));
}
Example #20
0
void QXmppSocksServer::slotNewConnection()
{
    QTcpServer *server = qobject_cast<QTcpServer*>(sender());
    if (!server)
        return;

    QTcpSocket *socket = server->nextPendingConnection();
    if (!socket)
        return;

    // register socket
    m_states.insert(socket, ConnectState);
    connect(socket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
}
Example #21
0
int MyWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: slotReadyRead(); break;
        case 1: slotSendMessage(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Example #22
0
void Stream::stream_url(QString url){

    request.setUrl(QUrl(url));
    request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");

    m_reply = manager->get(request);
   connect(m_reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
   connect(manager, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(replyFinished(QNetworkReply*)));

//    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
//            this, SLOT(slotError(QNetworkReply::NetworkError)));
//    connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
//            this, SLOT(slotSslErrors(QList<QSslError>)));
}
Example #23
0
KDSoapServerSocket::KDSoapServerSocket(KDSoapSocketList* owner, QObject* serverObject)
#ifndef QT_NO_OPENSSL
    : QSslSocket(),
#else
    : QTcpSocket(),
#endif
      m_owner(owner),
      m_serverObject(serverObject),
      m_delayedResponse(false),
      m_socketEnabled(true)
{
    connect(this, SIGNAL(readyRead()),
            this, SLOT(slotReadyRead()));
    m_doDebug = qgetenv("KDSOAP_DEBUG").toInt();
}
Example #24
0
   void CServerManager::disconnectFromServer()
   {
      m_connectToServer = false;
      m_tcpSocket->waitForDisconnected(0);
      m_tcpSocket->disconnectFromHost();

      disconnect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
      disconnect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
      disconnect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
         this,SLOT(slotError(QAbstractSocket::SocketError)));

      delete m_tcpSocket;

      qDebug("Disconnect from server - end");
   }
Example #25
0
Client::Client(const QString& host, int port, Gui *gui, QWidget* parent) : QWidget(parent), _nextBlockSize(0), _nameUser("")
{
	_isAuthorized = false;
	_nextBlockSize = 0;
	_socket = new QTcpSocket(this);
	_gui = gui;
	
	_socket->connectToHost(host, port);
	connect(_socket, SIGNAL(connected()), SLOT(slotConnected()));
	connect(_socket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
	connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)));
	
#ifdef DEBUG
	qDebug() << "Client has started";
#endif
}
Example #26
0
//--------------------utech--------------------utech--------------------utech--------------------
void ULoadVerInfo::loadVersion()
{
#ifdef U_DEVELOP
	qDebug() << "bool ULoadVerInfo::loadVersion() loaded.";
#endif
	netReply = accessMeneger->get(request);
	connect(netReply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
	connect(netReply, SIGNAL(error(QNetworkReply::NetworkError)),this, SLOT(slotError(QNetworkReply::NetworkError)));
	
	netRequestDone = false;
	
	timer = new QTimer(this);
	timer->setSingleShot(true);
	connect(timer, SIGNAL(timeout()), this, SLOT(slotTimeOut()));
	timer->start(timeDelay);
}
Example #27
0
void ConnectionManager::SetupConnection(const QString& serverName, int port)
{
    if(tcpSocket)
    {
        tcpSocket->close();
        tcpSocket->open(QIODevice::ReadWrite);
    }
    else
    {
        tcpSocket  = new QTcpSocket(this);

        connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
        connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)));
        connect(tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
    }

    tcpSocket->connectToHost(serverName, port);
}
bool QHttp::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: abort(); break;
    case 1: clientReply((const QHttpResponseHeader&)*((const QHttpResponseHeader*)static_QUType_ptr.get(_o+1))); break;
    case 2: clientDone((bool)static_QUType_bool.get(_o+1)); break;
    case 3: clientStateChanged((int)static_QUType_int.get(_o+1)); break;
    case 4: startNextRequest(); break;
    case 5: slotReadyRead(); break;
    case 6: slotConnected(); break;
    case 7: slotError((int)static_QUType_int.get(_o+1)); break;
    case 8: slotClosed(); break;
    case 9: slotBytesWritten((int)static_QUType_int.get(_o+1)); break;
    default:
	return QNetworkProtocol::qt_invoke( _id, _o );
    }
    return TRUE;
}
bool TcpClient::connectToHost(const QString &host, int port)
{
    m_pTcpSocket->connectToHost(host, port);

    if (!m_pTcpSocket->waitForConnected(10)) {
        emit connected(m_connectionState = -1);
        return false;
    } else {
        emit connected(m_connectionState = 0);
    }

    connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(m_pTcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this,         SLOT(slotError(QAbstractSocket::SocketError)));

    return true;
}
KNetworkByteStream::KNetworkByteStream( QObject *parent, const char */*name*/ )
 : ByteStream ( parent )
{
	kdDebug( 14151 ) << k_funcinfo << "Instantiating new KNetwork byte stream." << endl;

	// reset close tracking flag
	mClosing = false;

	mSocket = new KNetwork::KBufferedSocket;

	// make sure we get a signal whenever there's data to be read
	mSocket->enableRead( true );

	// connect signals and slots
	QObject::connect( mSocket, SIGNAL ( gotError ( int ) ), this, SLOT ( slotError ( int ) ) );
	QObject::connect( mSocket, SIGNAL ( connected ( const KResolverEntry& ) ), this, SLOT ( slotConnected () ) );
	QObject::connect( mSocket, SIGNAL ( closed () ), this, SLOT ( slotConnectionClosed () ) );
	QObject::connect( mSocket, SIGNAL ( readyRead () ), this, SLOT ( slotReadyRead () ) );
	QObject::connect( mSocket, SIGNAL ( bytesWritten ( int ) ), this, SLOT ( slotBytesWritten ( int ) ) );
}