void SocketServer::socketCallback(int /*fd*/, int mode) { sockaddr_in client4; sockaddr_in6 client6; sockaddr* client = 0; socklen_t size = 0; if (isIPv6) { size = sizeof(client6); client = reinterpret_cast<sockaddr*>(&client6); } else { size = sizeof(client4); client = reinterpret_cast<sockaddr*>(&client4); } int e; if (! ( mode & EventLoop::SocketRead ) ) return; for (;;) { eintrwrap(e, ::accept(fd, client, &size)); if (e == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { return; } serverError(this, AcceptError); close(); return; } //EventLoop::eventLoop()->unregisterSocket( fd ); accepted.push(e); serverNewConnection(this); } }
BtLocalDevice::BtLocalDevice(QObject *parent) : QObject(parent), securityFlags(QBluetooth::NoSecurity) { localDevice = new QBluetoothLocalDevice(this); connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)), this, SIGNAL(error(QBluetoothLocalDevice::Error))); connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), this, SIGNAL(hostModeStateChanged())); connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)), this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing))); connect(localDevice, SIGNAL(deviceConnected(QBluetoothAddress)), this, SLOT(connected(QBluetoothAddress))); connect(localDevice, SIGNAL(deviceDisconnected(QBluetoothAddress)), this, SLOT(disconnected(QBluetoothAddress))); connect(localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)), this, SLOT(pairingDisplayConfirmation(QBluetoothAddress,QString))); if (localDevice->isValid()) { deviceAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(deviceAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(deviceDiscovered(QBluetoothDeviceInfo))); connect(deviceAgent, SIGNAL(finished()), this, SLOT(discoveryFinished())); connect(deviceAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(discoveryError(QBluetoothDeviceDiscoveryAgent::Error))); connect(deviceAgent, SIGNAL(canceled()), this, SLOT(discoveryCanceled())); serviceAgent = new QBluetoothServiceDiscoveryAgent(this); connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); connect(serviceAgent, SIGNAL(finished()), this, SLOT(serviceDiscoveryFinished())); connect(serviceAgent, SIGNAL(canceled()), this, SLOT(serviceDiscoveryCanceled())); connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error))); socket = new QBluetoothSocket(SOCKET_PROTOCOL, this); connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socketStateChanged(QBluetoothSocket::SocketState))); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError))); connect(socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(readData())); setSecFlags(socket->preferredSecurityFlags()); server = new QBluetoothServer(SOCKET_PROTOCOL, this); connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection())); connect(server, SIGNAL(error(QBluetoothServer::Error)), this, SLOT(serverError(QBluetoothServer::Error))); } else { deviceAgent = 0; serviceAgent = 0; socket = 0; server = 0; } }
bool TCPReceiveRawNode::initialise() { if( !NodeControlBase::initialise() ) { return( false ); } connect( mNode->context()->qobject(), SIGNAL(frameStart(qint64)), this, SLOT(frameStart(qint64)) ); connect( &mServer, SIGNAL(newConnection()), this, SLOT(serverNewConnection()) ); return( true ); }