Exemplo n.º 1
0
bool Socket::Open()
{
    if (out_buffer_.get())
        return false;

    // Store peer address.
    address_ = ObtainRemoteAddress();
    if (address_ == UNKNOWN_NETWORK_ADDRESS)
    {
        sLog.outError("bool Socket::Open() address_ == UNKNOWN_NETWORK_ADDRESS!");
        return false;
    }

    // Hook for the manager.
    if (!manager_.OnSocketOpen(shared_from_this()))
    {
        sLog.outError("if (!manager_.OnSocketOpen(shared_from_this()))");
        return false;
    }

    closed_ = false;

    // Allocate buffers.
    out_buffer_.reset(new NetworkBuffer(outgoing_buffer_size_));
    read_buffer_.reset(new NetworkBuffer(protocol::READ_BUFFER_SIZE));

    // Start reading data from client
    StartAsyncRead();

    return true;
}
Exemplo n.º 2
0
void Socket::OnReadComplete(const boost::system::error_code& error, size_t bytes_transferred)
{
    if (error)
    {
        OnError(error);
        return;
    }

    if (bytes_transferred > 0)
    {
        read_buffer_->Commit(bytes_transferred);

        if (!ProcessIncomingData())
        {
            CloseSocket();
            return;
        }
    }

    StartAsyncRead();
}
Exemplo n.º 3
0
bool Socket::Open()
{
    if (out_buffer_.get())
        return false;

    address_ = ObtainRemoteAddress();
    if (address_ == UNKNOWN_NETWORK_ADDRESS)
        return false;

    if (!manager_.OnSocketOpen(shared_from_this()))
        return false;

    closed_ = false;

    out_buffer_.reset(new NetworkBuffer(outgoing_buffer_size_));
    read_buffer_.reset(new NetworkBuffer(protocol::READ_BUFFER_SIZE));

    StartAsyncRead();

    return true;
}
Exemplo n.º 4
0
	FORCEINLINE void StartSerializeBufferRead()
	{
		StartAsyncRead(SerializeBuffer);
	}
Exemplo n.º 5
0
	FORCEINLINE void StartStreamBufferRead()
	{
		StartAsyncRead(StreamBuffer);
	}