Jump to content
  • Advertisement
Sign in to follow this  
AbanoubNassem

boost asio async_read is not invoking the handler

This topic is 2548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

well, i made a static-lib. and i created this three classes in

Connection
http://pastebin.com/Ea9nLFUw

ConnectionFactory
http://pastebin.com/jeAg0cr7

Server
http://pastebin.com/x2ywkKCy

and i drevid from the static-lib and used this classes and it's working perfect

in my main.cpp

#include <iostream>
#include "auth_proto.h"
#include <Server.h>
#include <ConnectionFactory.h>
#include "AuthConnectionFactory.h"

using namespace std;
int main()
{
Auth_Setup();
try
{
boost::asio::io_service io_service;
boost::shared_ptr<ConnectionFactory> fact (new AuthConnectionFactory(io_service));
Server s(io_service,"5.113.195.156",9959,fact);
io_service.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}

return 0;
}


but the Receive() method is not invoking the handle_Receive() method!, can some one tell me what am doing wrong here!!!!???

Share this post


Link to post
Share on other sites
Advertisement
If you run "netstat -napl -t tcp" when the server is running, does the server show up as listening?
Why are you specifying a specific IP address to the endpoint for listening? Generally, you want to listen on 0.0.0.0 which means "all interfaces."
Also, I seem to recall that your socket needs to be open()-ed before you can pass it into accept(), but I'm not 100% sure.

Share this post


Link to post
Share on other sites

If you run "netstat -napl -t tcp" when the server is running, does the server show up as listening?
Why are you specifying a specific IP address to the endpoint for listening? Generally, you want to listen on 0.0.0.0 which means "all interfaces."
Also, I seem to recall that your socket needs to be open()-ed before you can pass it into accept(), but I'm not 100% sure.


the client is blocking anyconnection through "127.0.0.1" or so therefor am using an IP, and i dont think there is something wrong with the socket since it's working and the Receive() method is receiving but it's not calling handl_Receive() so i can use this data got me?

Share this post


Link to post
Share on other sites
In your "Connection" paste, line 77: bytes_transferred is of type size_t (which is always unsigned as per 7.17 and 7.18.3 of the C99 standard)

bytes_transferred <= 0 will always evaluate to false unless bytes_transferred is zero, you probably meant to write if (bytes_transferred > 0)

You should always post the up-to-date code, there was no way to tell you this from anything you showed on stackoverflow.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!