Ejemplo n.º 1
0
void CulistGui::acceptServerConnection()
{
    if(_tcpServerConnection == 0)
    {
        _tcpServerConnection = _tcpServer.nextPendingConnection();
        connect(_tcpServerConnection, SIGNAL(readyRead()),
                this, SLOT(processServerConnectionData()));
        connect(_tcpServerConnection, SIGNAL(error(QAbstractSocket::SocketError)),
                this, SLOT(processServerConnectionError(QAbstractSocket::SocketError)));

		connect(_tcpServerConnection, SIGNAL(disconnected()),
                this, SLOT(processServerConnectionClosed()));

		
		ui->statusBar->showMessage( "Accepted connection" );
		if( _actAsProxyServer )
		{
			connectToTcpServer();
		}
    }
	else
	{
		ui->statusBar->showMessage( "Rejected 2nd connection" );
	}
}
Ejemplo n.º 2
0
bool
connectToServer(NConnect_State &state) {
	switch (state.type) {
	case SAT_UNIX:
		return connectToUnixServer(state.s_unix);
	case SAT_TCP:
		return connectToTcpServer(state.s_tcp);
	default:
		throw RuntimeException("Unknown address type");
	}
}
Ejemplo n.º 3
0
int
connectToServer(const StaticString &address) {
	TRACE_POINT();
	switch (getSocketAddressType(address)) {
	case SAT_UNIX:
		return connectToUnixServer(parseUnixSocketAddress(address));
	case SAT_TCP: {
		string host;
		unsigned short port;
		
		parseTcpSocketAddress(address, host, port);
		return connectToTcpServer(host, port);
	}
	default:
		throw ArgumentException(string("Unknown address type for '") + address + "'");
	}
}
Ejemplo n.º 4
0
RoboControllerSDK::RoboControllerSDK(QString serverAddr/*=QString("127.0.0.1")*/,
                                     quint16 udpStatusPortSend/*=14550*/,
                                     quint16 udpStatusPortListen/*=14555*/,
                                     quint16 udpControlPort/*=14560*/,
                                     quint16 tcpPort/*=14500*/) :
    mTcpSocket(NULL),
    mUdpStatusSocket(NULL),
    mUdpControlSocket(NULL)
{
    mStopped = true;
    mWatchDogTimeMsec = 1000;
    mMsgCounter = 0;

    // Ping Timer
    connect( &mPingTimer, SIGNAL(timeout()), this, SLOT(onPingTimerTimeout()));

    // >>>>> TCP Socket
    mTcpSocket = new QTcpSocket(this);

    mServerAddr = serverAddr;
    mTcpPort = tcpPort;

    connect(mTcpSocket, SIGNAL(readyRead()),
            this, SLOT(onTcpReadyRead()));
    connect(mTcpSocket, SIGNAL(hostFound()),
            this, SLOT(onTcpHostFound()));
    connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(onTcpError(QAbstractSocket::SocketError)));

    try
    {
        connectToTcpServer();
    }
    catch( RcException &e )
    {
        qDebug() << e.getExcMessage();
        throw e;
    }
    // <<<<< TCP Socket

    // >>>>> UDP Sockets
    mUdpControlSocket = new QUdpSocket(this);
    mUdpStatusSocket = new QUdpSocket(this);

    mUdpControlPortSend = udpControlPort;
    mUdpStatusPortSend = udpStatusPortSend;
    mUdpStatusPortListen = udpStatusPortListen;

    /*connect( mUdpControlSocket, SIGNAL(readyRead()),
             this, SLOT(onUdpControlReadyRead()) ); // The control UDP Socket does not receive!*/
    connect( mUdpStatusSocket, SIGNAL(readyRead()),
             this, SLOT(onUdpStatusReadyRead()) );

    connect( mUdpControlSocket, SIGNAL(error(QAbstractSocket::SocketError)),
             this, SLOT(onUdpControlError(QAbstractSocket::SocketError)) );
    connect( mUdpStatusSocket, SIGNAL(error(QAbstractSocket::SocketError)),
             this, SLOT(onUdpStatusError(QAbstractSocket::SocketError)) );

    try
    {
        connectToUdpServers();
    }
    catch( RcException &e )
    {
        qDebug() << e.getExcMessage();
        throw e;
    }

    // <<<<< UDP Sockets
    mMotorCtrlMode = mcPID; // RoboController is in PID mode by default

    // Start thread
    mStopped = false;
    start();
}