ASIO - TCP Socket never getting data

92 views Asked by At

My problem is that I don't seem to be ever receiving the packets I send as the available() function always returns 0. I am using the standalone version of Asio on Windows. I am not a complete newbie and have used ASIO before (but I'm still pretty terrible).

I have tried opening moveSoc beforehand but that didn't help. I also have tried binding endPoint to acceptor but that results in an invalid argument error.

Set Up

asio::error_code errCode;

asio::ip::address oponentAdress = checkPoint.address(); //Adress of a valid UDP endpoint
std::cout << checkPoint.address().to_string() << std::endl;
endPoint.address(oponentAdress);
endPoint.port(portNum);

acceptor->listen();
moveSoc.connect(endPoint, errCode);

std::cout << errCode.message() << std::endl;
acceptor->accept(moveSoc, errCode);
std::cout << errCode.message() << std::endl;
std::cout << "Found Client!" << std::endl;

Sending code

void ClientHandler::Outbound()
{
    moveSoc.write_some(asio::buffer(m_outgoingPacs, m_packetNum)); //Packet num is a valid number
}

Reading code

bool ClientHandler::Inbound()
{
    uint bytesToRead = moveSoc.available();

    if (bytesToRead > 0)
        moveSoc.read_some(asio::buffer(m_incomingPacs, bytesToRead));
    return (bytesToRead > 0);
}
0

There are 0 answers