|
UniSet
2.6.0
|
00001 /* 00002 * Copyright (c) 2015 Pavel Vainerman. 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as 00006 * published by the Free Software Foundation, version 2.1. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Lesser Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 */ 00016 // ------------------------------------------------------------------------- 00017 #ifndef UTCPStream_H_ 00018 #define UTCPStream_H_ 00019 // ------------------------------------------------------------------------- 00020 #include <string> 00021 #include <Poco/Net/SocketStream.h> 00022 #include "PassiveTimer.h" // for timeout_t 00023 // ------------------------------------------------------------------------- 00024 namespace uniset 00025 { 00026 00031 class UTCPStream: 00032 public Poco::Net::StreamSocket 00033 { 00034 public: 00035 00036 UTCPStream( const Poco::Net::StreamSocket& so ); 00037 UTCPStream(); 00038 virtual ~UTCPStream(); 00039 00040 void create( const std::string& hname, int port, timeout_t tout_msec = 1000 ); 00041 00042 bool isConnected() noexcept; 00043 00044 // set keepalive params 00045 // return true if OK 00046 bool setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl = 2 ); 00047 00048 bool isSetLinger() const; 00049 void forceDisconnect(); // disconnect() без ожидания (с отключением SO_LINGER) 00050 void disconnect(); 00051 00052 // -------------------------------------------------------------------- 00053 int getSocket() const; 00054 timeout_t getTimeout() const; 00055 00056 protected: 00057 00058 private: 00059 00060 }; 00061 // ------------------------------------------------------------------------- 00062 } // end of uniset namespace 00063 // ------------------------------------------------------------------------- 00064 #endif // UTCPStream_H_ 00065 // -------------------------------------------------------------------------
1.7.6.1