Example #1
0
GTcpServer::GTcpServer(QObject *parent,VM *pVM)  : QTcpServer(parent)
{
	this->pVM = pVM;
	this->pParaList = ring_list_new(0);
	strcpy(this->cacceptErrorEvent,"");
	strcpy(this->cnewConnectionEvent,"");

	QObject::connect(this, SIGNAL(acceptError(QAbstractSocket::SocketError)),this, SLOT(acceptErrorSlot()));
	QObject::connect(this, SIGNAL(newConnection()),this, SLOT(newConnectionSlot()));

}
Example #2
0
GBluetoothServer::GBluetoothServer(QBluetoothServiceInfo::Protocol x,QObject *parent,VM *pVM)  : QBluetoothServer(x,parent)
{
	this->pVM = pVM;
	this->pParaList = ring_list_new(0);
	strcpy(this->cerrorEvent,"");
	strcpy(this->cnewConnectionEvent,"");

	QObject::connect(this, SIGNAL(error(QBluetoothServer::Error)),this, SLOT(errorSlot()));
	QObject::connect(this, SIGNAL(newConnection()),this, SLOT(newConnectionSlot()));

}
Example #3
0
MdCharmApplication::MdCharmApplication( int &argc, char **argv ) :
    QApplication( argc, argv )
{
    _isRunning = false;
    QString serverName = "MdCharm-Server";
    QLocalSocket socket;
    socket.connectToServer( serverName );

    if ( socket.waitForConnected( 500 ) ) {
        QTextStream stream( &socket );
        QStringList args = arguments();

        if ( args.count() > 1 ) {
            args.removeFirst();//remove app self path
            stream << args.join( "," );
        } else {
            stream << QString();
        }

        stream.flush();
        socket.waitForBytesWritten();
        _isRunning = true;
        return;
    }

    localServer = new QLocalServer( this );
    connect( localServer, SIGNAL( newConnection() ),
             this, SLOT( newConnectionSlot() ) );

    if ( !localServer->listen( serverName ) ) {
        if ( localServer->serverError() == QAbstractSocket::AddressInUseError
             && QFile::exists( localServer->serverName() ) ) {
            QFile::remove( localServer->serverName() );
            localServer->listen( serverName );
        }
    }
}