예제 #1
0
	bool UTPSocket::connectTo(const net::Address& addr)
	{
		if (!bt::Globals::instance().isUTPEnabled())
			return false;

		UTPServer & srv = bt::Globals::instance().getUTPServer();
		reset();

		conn = srv.connectTo(addr);
		Connection::Ptr ptr = conn.toStrongRef();
		if (!ptr)
			return false;

		m_state = CONNECTING;
		ptr->setBlocking(blocking);
		if (blocking)
		{
			bool ret = ptr->waitUntilConnected();
			if (ret)
				m_state = CONNECTED;

			return ret;
		}

		return ptr->connectionState() == CS_CONNECTED;
	}
예제 #2
0
	void UTPSocket::setBlocking(bool on)
	{
		blocking = on;
		Connection::Ptr ptr = conn.toStrongRef();
		if (ptr)
			ptr->setBlocking(on);
	}
예제 #3
0
	UTPSocket::UTPSocket(Connection::WPtr conn)
			: net::SocketDevice(bt::UTP), 
			conn(conn), 
			blocking(true), 
			polled_for_reading(false), 
			polled_for_writing(false)
	{
		Connection::Ptr ptr = conn.toStrongRef();
		if (ptr)
		{
			setRemoteAddress(ptr->remoteAddress());
			ptr->setBlocking(blocking);
			m_state = CONNECTED;
		}
	}