X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Fsg_netChannel.hxx;h=538618c3f0187ef930d5d717dfd9d8a434dcdf72;hb=70c5d605641b628039f75cb8761ce783a17a5bdf;hp=5c7d19577fe0b3ce907a1e32c17c7bbb0c78dd4f;hpb=878b504f8e044bc0e59903caa8641492421b76d8;p=simgear.git diff --git a/simgear/io/sg_netChannel.hxx b/simgear/io/sg_netChannel.hxx index 5c7d1957..538618c3 100644 --- a/simgear/io/sg_netChannel.hxx +++ b/simgear/io/sg_netChannel.hxx @@ -16,7 +16,7 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA For further information visit http://plib.sourceforge.net @@ -54,24 +54,23 @@ #define SG_NET_CHANNEL_H #include -#include +#include +#include namespace simgear { -class HostLookup; - +class NetChannelPoller; + class NetChannel : public Socket { - bool closed, connected, accepting, write_blocked, should_delete ; - NetChannel* next_channel ; - SGSharedPtr host_lookup ; + bool closed, connected, accepting, write_blocked, should_delete, resolving_host ; + std::string host; int port; - friend bool netPoll (unsigned int timeout); - - void doConnect(); + friend class NetChannelPoller; + NetChannelPoller* poller; public: NetChannel () ; @@ -103,6 +102,7 @@ public: void handleReadEvent (void); void handleWriteEvent (void); + int handleResolve (void); // These are meant to be overridden. virtual void handleClose (void) { @@ -112,9 +112,21 @@ public: virtual void handleWrite (void); virtual void handleAccept (void); virtual void handleError (int error); - - static bool poll (unsigned int timeout = 0 ) ; - static void loop (unsigned int timeout = 0 ) ; + +}; + +class NetChannelPoller +{ + typedef std::vector ChannelList; + ChannelList channels; +public: + void addChannel(NetChannel* channel); + void removeChannel(NetChannel* channel); + + bool hasChannels() const { return !channels.empty(); } + + bool poll(unsigned int timeout = 0); + void loop(unsigned int timeout = 0); }; } // of namespace simgear