root/trunk/dep/src/sockets/StreamSocket.cpp @ 2

Revision 2, 2.1 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1#include "StreamSocket.h"
2#include "ISocketHandler.h"
3
4
5#ifdef SOCKETS_NAMESPACE
6namespace SOCKETS_NAMESPACE {
7#endif
8
9
10StreamSocket::StreamSocket(ISocketHandler& h) : Socket(h)
11,m_bConnecting(false)
12,m_connect_timeout(5)
13,m_flush_before_close(true)
14,m_connection_retry(0)
15,m_retries(0)
16,m_call_on_connect(false)
17,m_b_retry_connect(false)
18,m_line_protocol(false)
19,m_shutdown(0)
20{
21}
22
23
24StreamSocket::~StreamSocket()
25{
26}
27
28
29void StreamSocket::SetConnecting(bool x)
30{
31        if (x != m_bConnecting)
32        {
33                m_bConnecting = x;
34                if (x)
35                {
36                        SetTimeout( GetConnectTimeout() );
37                }
38                else
39                {
40                        SetTimeout( 0 );
41                }
42        }
43}
44
45
46bool StreamSocket::Connecting()
47{
48        return m_bConnecting;
49}
50
51
52bool StreamSocket::Ready()
53{
54        if (GetSocket() != INVALID_SOCKET && !Connecting() && !CloseAndDelete())
55                return true;
56        return false;
57}
58
59
60void StreamSocket::SetConnectTimeout(int x)
61{
62        m_connect_timeout = x;
63}
64
65
66int StreamSocket::GetConnectTimeout()
67{
68        return m_connect_timeout;
69}
70
71
72void StreamSocket::SetFlushBeforeClose(bool x)
73{
74        m_flush_before_close = x;
75}
76
77
78bool StreamSocket::GetFlushBeforeClose()
79{
80        return m_flush_before_close;
81}
82
83
84int StreamSocket::GetConnectionRetry()
85{
86        return m_connection_retry;
87}
88
89
90void StreamSocket::SetConnectionRetry(int x)
91{
92        m_connection_retry = x;
93}
94
95
96int StreamSocket::GetConnectionRetries()
97{
98        return m_retries;
99}
100
101
102void StreamSocket::IncreaseConnectionRetries()
103{
104        m_retries++;
105}
106
107
108void StreamSocket::ResetConnectionRetries()
109{
110        m_retries = 0;
111}
112
113
114void StreamSocket::SetCallOnConnect(bool x)
115{
116        Handler().AddList(GetSocket(), LIST_CALLONCONNECT, x);
117        m_call_on_connect = x;
118}
119
120
121bool StreamSocket::CallOnConnect()
122{
123        return m_call_on_connect;
124}
125
126
127void StreamSocket::SetRetryClientConnect(bool x)
128{
129        Handler().AddList(GetSocket(), LIST_RETRY, x);
130        m_b_retry_connect = x;
131}
132
133
134bool StreamSocket::RetryClientConnect()
135{
136        return m_b_retry_connect;
137}
138
139
140void StreamSocket::SetLineProtocol(bool x)
141{
142        m_line_protocol = x;
143}
144
145
146bool StreamSocket::LineProtocol()
147{
148        return m_line_protocol;
149}
150
151
152void StreamSocket::SetShutdown(int x)
153{
154        m_shutdown = x;
155}
156
157
158int StreamSocket::GetShutdown()
159{
160        return m_shutdown;
161}
162
163
164
165
166#ifdef SOCKETS_NAMESPACE
167} // namespace SOCKETS_NAMESPACE {
168#endif
169
Note: See TracBrowser for help on using the browser.