Hi, This is the code i'm trying to run. server(boost::asio::io_service& io_service, short port) : io_service_(io_service), socket_(io_service) { try { udp::endpoint localEndpoint( udp::v4(), port ); socket_.bind( localEndpoint ); } catch( boost::system::system_error & error ) { std::cerr << "Exception: " << error.what() << "\n"; } socket_.async_receive_from( boost::asio::buffer(data_, max_length), sender_endpoint_, boost::bind(&server::handle_receive_from, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred) ); } and the error i get is "The file handle supplied is not valid" I guess this means the socket itself is invalid but if i put the local end point into the constructor for the socket_ as below it works fine. socket_(io_service, udp::endpoint( udp::v4(), port ) ) Thanks, Tim.
What message and the code of the system_error you've got? Probably, it will explain the reason of the error. By the way, most of the asio functions have no-throw version that gets error_code& as a paramter and fills it in case of error.