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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
socketport is meant as the base class for all kinds of ports. Are you suggesting a new socketlisten specifically for tcp "server" binding?
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.
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