예제 #1
0
bool CWSAThread::startup()
{
    m_maxwsaeventsize = WSA_MAXIMUM_WAIT_EVENTS;
    m_keepalivetimeout = CGlobalConfig::getInstance()->getKeepaliveTimer();
    m_keepaliveinterval = m_keepalivetimeout / 2;
    m_serverip = CGlobalConfig::getInstance()->getListenIp();
    m_serverport = CGlobalConfig::getInstance()->getListenPort();

    m_sendbufsize = CGlobalConfig::getInstance()->getSocketSendBuf();
    m_readbufsize = CGlobalConfig::getInstance()->getSocketRecvBuf();

    m_recvbuflen = m_sendbufsize;
    if (m_sendbufsize < m_readbufsize)
    {
        m_recvbuflen = m_readbufsize;
    }
    if (m_recvbuflen < MAX_SEND_SIZE)
    {
        m_recvbuflen = MAX_SEND_SIZE;
    }
    m_recvbuflen += MAX_SEND_SIZE;

    m_recvbuffer = new char[m_recvbuflen];
    if (!m_recvbuffer)
    {
        LOG(_ERROR_, "CWSAThread::startup() error, _new char[m_recvbuflen] failed, m_recvbuflen=%d", m_recvbuflen);
        exit(-1);
    }

    if (!doListen())
    {
        LOG(_ERROR_, "CWSAThread::startup() error, doListen() failed");
        return false;
    }

    if (!start())
    {
        LOG(_ERROR_, "CWSAThread::startup() error, start() failed");
        return false;
    }

    continues();

    return true;
}
예제 #2
0
파일: BaseTCP.hpp 프로젝트: twManu/libmanu
	/*! @detail
	 * Listen on socket. The implementation should invoke like this
	 *        bool TCP::Listen(unsigned int addr, unsigned short port, int maxcon) {
	 *	        if( !BaseTCP::Listen(addr, port, maxcon) ) return false;
	 *               ...
	 *        }
	 * @param host - imply the interface to binding. if not configured, any interface applied
	 * @param maxcon - maximum connection
	 * @return false - failure
	 *          true - successful
	 */
	bool Listen(int maxcon) { return doListen(maxcon); }
	bool QtUdpSocketPlugin::listen(const QString &, uint16_t port, const std::function<void(QString)> & callback) {
		_helperReceiveCallback = callback;
		emit doListen(port);
		return true;
	}
	QtUdpSocketPlugin::QtUdpSocketPlugin() : _socket(nullptr), _helperReceiveCallback(), _checkerReceiveCallback(), _messageCounter(0), _conditionLock(), _conditionVariable(), _targetHost(), _targetPort(0) {
		QObject::connect(this, SIGNAL(doListen(quint16)), this, SLOT(onListen(quint16)));
		QObject::connect(this, SIGNAL(doConnect(QString, quint16)), this, SLOT(onConnect(QString, quint16)));
		QObject::connect(this, SIGNAL(doSendMessage(QString)), this, SLOT(onSendMessage(QString)));
		QObject::connect(this, SIGNAL(doDisconnect()), this, SLOT(onDisconnect()));
	}
예제 #5
0
Error Socket::listen(int backlog)
{
	return doListen(backlog);
}
예제 #6
0
void RtpSinker::OnMessage(talk_base::Message *msg) {
    if(msg->message_id == MSG_START_LISTEN ) {
        doListen();
    }
}