Ok thanks...now I'm starting with an iterative server which serves one request at a time.
   
    boost::asio::ip::tcp::acceptor acceptor(io_service);
    boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port);
    acceptor.open(endpoint.protocol());
    int listensd=acceptor.native();

    acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
    acceptor.bind(endpoint);
    acceptor.listen(3);

    while(1)
    {
        acceptor.accept(sock);
        sock.write_some(boost::asio::buffer(data, data.size()));
        int connectsd=sock.native();
        sock.close();
    }

If I would make concurrent this server, when I have to work?
In C it is enough to make:

int listen sd,connsd;  //socket descriptor
pid_t pid;

listensd=socket(...);
bind(listensd,...);
listen(listensd,..);
for(;;)
{
    connsd=accept(listensd,..);
    if((pid=fork())==0)   //child process
    {
        close(listensd);    //close the listening socket
        do_it(connsd);    //serve th request
        close(connsd);   //close the connection socket
        exit(0);
    }
    close(connsd);      //parent close the connection socket
}

I don't knwo how make thisin boost...any ideas?thanks




Da: Rutger ter Borg <rutger@terborg.net>
A: boost-users@lists.boost.org
Inviato: Gio 3 marzo 2011, 10:26:36
Oggetto: Re: [Boost-users] Async_accept

On 03/03/2011 10:13 AM, Marco Piacentini wrote:
> Hi guys...
> Reading docs, I understand that acceptor.async_accept(), accept a
> connection and immediately return, so the acceptor can accept another
> concurrent connection request...and in the meanwhile the handler can
> process the request...it's right?

No, the asynchronous model works different: you issue a request for an operation, such as async_accept, and your program will be called back when that operation has been completed (or aborted). In this case, the handler will be invoked after your request for accepting a connection has been completed. Asio will not start accepting another connecting until you issue another request, which should be done after your previous request has been completed.

HtH,
Cheers,

Rutger

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users