0

I am working on a daemon, in C using libevent library, which accepts TCP connections and creates bufferevent (socket) for each accepted connection as following

struct bufferevent *bev = bufferevent_socket_new(
            base, 
            sfd, 
            BEV_OPT_CLOSE_ON_FREE);

What I what to do is to store the created bufferevent (sockets) for later use, say, in a array struct event_info myevents[MAX_EVENTS], where event_info is defined as

struct event_info
{
  bufferevent* bev;
  /* additional standard data fields */
};

Later, when I am done with the socket I remove the event from the event base and remove the event_info from the array.

So, is it safe to store a pointer to a newly created bufferevent (created by bufferevent_socket_new) in the array?

fade2black
  • 546
  • 1
  • 10
  • 26

0 Answers0