bool SocketWrapper::openSocket( int domain, int type, int protocol, bool registersock, bool nonblock) { if (INVALID_SOCKET != sock) { HAGGLE_ERR("socket already open\n"); return false; } sock = ::socket(domain, type, protocol); if (INVALID_SOCKET == sock) { HAGGLE_ERR("could not open socket\n"); return false; } if (!setNonblock(nonblock)) { closeSocket(); return false; } if (registersock && !registerSocket()) { closeSocket(); return false; } return true; }
/* accept a UNIX connection */ static int unixlSelectedR(Socket *self, int fd) { SocketUNIX *sock; int newfd, id; unsigned char idbuf[4]; /* accept it */ newfd = accept(fd, NULL, NULL); if (newfd < 0) return 0; /* then make the return */ sock = (SocketUNIX *) newSocket(sizeof(SocketUNIX)); newSocketWritable(sock, newfd); sock->ssuper.vtbl = &unixVTbl; /* register it */ id = registerSocket((Socket *) sock, NULL); /* then tell the other side */ muxCommand(stdoutSocket, 'c', self->id); muxPrepareInt(idbuf, id); stdoutSocket->vtbl->write(stdoutSocket, idbuf, 4); return 0; }
NZMQT_INLINE ZMQSocket* ZMQContext::createSocket(ZMQSocket::Type type_, QObject* parent_) { ZMQSocket* socket = createSocketInternal(type_); registerSocket(socket); socket->setParent(parent_); return socket; }
Manager::Manager(QObject *_parent) : QObject(_parent) , m_emulator(new DeviceEmulator(90, 0, 5)) , tcpServer(new QTcpServer(this)) , clientsConnected(0) { connect(tcpServer, SIGNAL(newConnection()), this, SLOT(registerSocket())); }