Boost logo

Boost Users :

From: Jean-Sebastien Stoezel (js.stoezel_at_[hidden])
Date: 2008-08-07 13:20:43


Hi,

thanks for the quick answer. By port number and ip address of an
acceptor" I mean the address and the port of the ip interface the
acceptor is listening on.
In most of the case I've worked on, I used the specify the port I
wanted to listen on, though for this special case, I do not want the
acceptor to specify a port number.

Then when I do:

boost::asio::ip::tcp::acceptor acceptor(m_IoService);

when I call

boost::asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint();

I get an exception as follow:
"The file handle supplied is not valid"

I need to know the ip address and the port number fo the acceptor
before calling the accept method.

Any thoughts?

Thanks

On 8/7/08, Igor R <boost.lists_at_[hidden]> wrote:
> What do you mean by "port number and ip address of an acceptor"? If
> you want to know the address of your local "endpoint", then you can
> get it:
>
> boost::asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint();
>
> then get its address and port:
> endpoint.address();
> endpoint.port();
>
> But if you want to get the address of your peer, then you can get it
> from accept() or async_accept() -- please see their descriptions.
>
> P.S. IMHO, asio has *very* clear, readable, and useful manual, and I'm
> sure you could find there aswers to most of your questions:
> http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio.html
>
> 2008/8/7, Jean-Sebastien Stoezel <js.stoezel_at_[hidden]>:
> > Hi,
> >
> > How to get the port number and ip address of an acceptor?
> >
> > I tried this:
> >
> > boost::asio::ip::tcp::acceptor acceptor(m_IoService);
> > boost::asio::ip::tcp::acceptor myEndPoint(m_IoService);
> >
> > acceptor.get_option(myEndPoint);
> >
> > But this does not compile, Iget a couple of errors in
> > win_iocp_socket_service.hpp like this one:
> >
> > Error 8 error C2039: 'level' : is not a member of
> > 'boost::asio::basic_socket_acceptor<Protocol>'
> >
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net