Boost logo

Boost Users :

Subject: [Boost-users] [asio] Problem Assignin a File Descriptor to posix:basic_stream_descriptor
From: Nader Salehi (Nader.Salehi_at_[hidden])
Date: 2010-03-17 17:42:45


Hi All,

I want to use Boost ASIO as an event manager in a server which, among
other things, asynchronously writes into a file. I use open() to
create my file and then try to assign it to a posix::stream_descriptor
object. However, the following simple code throws an "Operation not
permitted" exception.

int
main ()
{
    boost::asio::io_service ioService;
    int fd = open("./asio_sample.txt",
                  O_WRONLY | O_CREAT | O_ASYNC | O_NONBLOCK,
                  S_IRUSR | S_IWUSR | S_IRGRP);
    assert(fd != -1);
    boost::asio::posix::stream_descriptor descriptor(ioService);
    descriptor.assign(fd);

    return 0;
}

I traced down the epoll_reactor::register_descriptor() where the
function fails to add the descriptor to the poll list.

Any idea what I am doing wrong? I would appreciate any comment.

Cheers,
Nader


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