UniSet 2.32.1
UTCPStream.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// -------------------------------------------------------------------------
17#ifndef UTCPStream_H_
18#define UTCPStream_H_
19// -------------------------------------------------------------------------
20#include <string>
21#include <Poco/Net/SocketStream.h>
22#include "PassiveTimer.h" // for timeout_t
23// -------------------------------------------------------------------------
24namespace uniset
25{
26
32 public Poco::Net::StreamSocket
33 {
34 public:
35
36 UTCPStream( const Poco::Net::StreamSocket& so );
37 UTCPStream();
38 virtual ~UTCPStream();
39
40 void create( const std::string& hname, uint16_t port, timeout_t tout_msec = 1000 );
41
42 bool isConnected() const noexcept;
43
44 // set keepalive params
45 // return true if OK
46 bool setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl = 2 );
47
48 bool isSetLinger() const;
49 void forceDisconnect(); // disconnect() без ожидания (с отключением SO_LINGER)
50 void disconnect();
51
52 // --------------------------------------------------------------------
53 int getSocket() const;
54 timeout_t getTimeout() const;
55
56 protected:
57
58 private:
59
60 };
61 // -------------------------------------------------------------------------
62} // end of uniset namespace
63// -------------------------------------------------------------------------
64#endif // UTCPStream_H_
65// -------------------------------------------------------------------------
Definition UTCPStream.h:33
Definition Calibration.h:27