Back to index

im-sdk  12.3.91
Public Member Functions | Private Member Functions
IMSocketListen Class Reference

#include <IMUtil.hh>

List of all members.

Public Member Functions

bool errorp ()
bool listen (IMSocketAddressVec &endvec)
IMSocketTransaccept ()
 IMSocketListen ()
 ~IMSocketListen ()

Private Member Functions

enum IMSocket::LISTEN_STATUS
IMSocketVec sockvec 
IMSocketListen (const IMSocketListen &a)
IMSocketListenoperator= (const IMSocketListen &a)

Detailed Description

Definition at line 180 of file IMUtil.hh.


Constructor & Destructor Documentation

enum IMSocket::LISTEN_STATUS IMSocketVec sockvec IMSocketListen::IMSocketListen ( const IMSocketListen a) [abstract, private]

Definition at line 923 of file IMUtil.cpp.

Definition at line 928 of file IMUtil.cpp.

{
    delete_all(sockvec);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 846 of file IMUtil.cpp.

{
    IMSocketVec::iterator it;
    IMSocket *pims;

    if (status != IMSocket::OPEN) return NULL;

#if defined(HAVE_POLL)
    int fd, i, n;
    struct pollfd *fds;

    i = sockvec.size();
    if (i <= 0) return NULL;
    fds = new struct pollfd[i];
    if (!fds) return NULL;
    for (n = 0, it = sockvec.begin(); it != sockvec.end(); it++) {
       pims = *it;
       fd = pims->get_fd();
       if (fd < 0) continue;
       fds[n].fd = fd;
       fds[n].events = POLLIN;
       fds[n].revents = 0;
       n++;
    }
    if (n > 0) {
       i = poll(fds, n, -1);
       if (i > 0) {
           for (i = 0; i < n; i++) {
              if (fds[i].revents) {
                  fd = fds[i].fd;
                  for (it = sockvec.begin(); it != sockvec.end(); it++) {
                     pims = *it;
                     if (fd == pims->get_fd()) {
                         delete [] fds;
                         return pims->accept();
                     }
                  }
              }
           }
       }
    }
    delete [] fds;

#elif defined(HAVE_SELECT)
    int fd, maxfd;
    fd_set fds;
    FD_ZERO(&fds);

    maxfd = -1;
    for (it = sockvec.begin(); it != sockvec.end(); it++) {
       pims = *it;
       fd = pims->get_fd();
       if (fd < 0) continue;
       if (fd > maxfd) maxfd = fd;
       FD_SET(fd, &fds);
    }
    if (maxfd < 0) return NULL;
    maxfd++;
    fd = select(maxfd, &fds, NULL, NULL, NULL);
    if (fd <= 0) return NULL;
    for (it = sockvec.begin(); it != sockvec.end(); it++) {
       pims = *it;
       fd = pims->get_fd();
       if (fd < 0) continue;
       if (FD_ISSET(fd, &fds)) {
           fd = pims->accept();
           if (fd < 0) return NULL;
           return fd;
       }
    }
#else
#error "We need poll() or select() to multiplex socket handles"
#endif

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSocketListen::errorp ( ) [inline]

Definition at line 194 of file IMUtil.hh.

    { return (status == IMSocket::ERROR); }

Definition at line 817 of file IMUtil.cpp.

{
    if (status == IMSocket::ERROR) return false;
    if (status == IMSocket::OPEN) return true;

    IMSocketAddressVec::iterator ait;
    for (ait = endvec.begin(); ait!= endvec.end(); ait++) {
       if (ait->create_sockets(sockvec) < 0) return false;
    }

    IMSocketVec::iterator it;
    IMSocket *pims;
    for (it = sockvec.begin(); it != sockvec.end(); it++) {
       pims = *it;
       if (pims->get_status() == IMSocket::ERROR) return false;
       if (pims->get_status() == IMSocket::OPEN) continue;
       if (!pims->listen()) {
           status = IMSocket::ERROR;
           return false;
       }
    }
    status = IMSocket::OPEN;

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IMSocketListen& IMSocketListen::operator= ( const IMSocketListen a) [private]

The documentation for this class was generated from the following files: