Menu

Socket: Nonblocking listen

2000-11-28
2000-11-28
  • Petr "Fers" Ferschmann

    Hello I need to listen on many ports or IPs. It is not good to have thread for each listen socket. I read in documentation that I can use select or poll for socket in listen mode. So I want to change some things in SocketService and SocketPort. So I can attach to SocketService more socket ports. Some listening and some some pending.

    I think it will be good to make base class fot SocketPort and SocketListen.

    I can make the posix version but I can't make it for Win32. What do you think Dyfet? Can you write me your opinion?

     
    • David Sugar

      David Sugar - 2000-11-28

      socketport is meant as the base class for all kinds of ports.  Are you suggesting a new socketlisten specifically for tcp "server" binding?

       
      • Petr "Fers" Ferschmann

        Yes you can use poll/select for watching for new connections on listen port.

        I am working on it. I will send you my results.

         
    • Anonymous

      Anonymous - 2000-11-28

      I had so far just a brief look at the CommonC++ library, but I asked myself the same question: how to I listen on multiple sockets effeciently? I thought about a 'Pollable' interface (a.k.a pure virtual class), with the (only) member function 'int fd() const' returning the file (socket) descriptor (handler). Not only from Socket, but also from iostream could then Pollable classes be derived. A FDSet (PollableSet) class could then implement the poll() method. Does this make sense?

      Please note also the ambiguity of the 'timeout' parameter to Socket::isPending(): the semantic of poll() and select() differ in a subtile way: for poll() the 'timeout' is a mere _minimum_ gathering time, this time is spent inside the poll() call even, if files/sockets refered by their decriptors are ready, while select() returns as soon as they are ready, no later (well as soon as the scheduler allows) than 'timeout'.

      Guenther

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.