reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Connection.hxx
Go to the documentation of this file.
1#ifndef RESIP_Connection_hxx
2#define RESIP_Connection_hxx
3
4#include <list>
5
7//#include "rutil/Fifo.hxx"
8#include "rutil/Socket.hxx"
9#include "rutil/FdPoll.hxx"
10#include "rutil/Timer.hxx"
15
16namespace resip
17{
18
19class Message;
20class TlsConnection;
21class ConnectionManager;
22class Connection;
23class Compression;
24
30
36class Connection : public ConnectionBase,
37 public ConnectionLruList,
38 public ConnectionReadList,
39 public ConnectionWriteList,
40 public FlowTimerLruList,
41 public FdPollItemIf
42{
43 friend class ConnectionManager;
45
46 public:
48 virtual ~Connection();
49
57 Socket getSocket() const {return mWho.mFlowKey;}
58
60 virtual bool hasDataToRead();
62 virtual bool isGood();
63 virtual bool checkConnectionTimedout();
64 virtual bool isWritable();
65 virtual bool transportWrite(){return false;}
66
69
71 int performWrite();
72
81 bool performWrites(unsigned int max=0);
82
84 void ensureWritable();
85
90 int read();
91
98 bool performReads(unsigned int max=0);
99
101 void enableFlowTimer();
102 bool isFlowTimerEnabled() { return mFlowTimerEnabled; }
103
106 // also covers the DNS resolver's sockets (see ExternalDns)
112 bool isServer()const;
113 protected:
115 virtual int read(char* /* buffer */, const int /* count */) { return 0; }
117 virtual int write(const char* /* buffer */, const int /* count */) { return 0; }
118 virtual void onDoubleCRLF();
119 virtual void onSingleCRLF();
120 virtual void onWsClose(const Data& payload);
121 virtual void onWsPing(const Data& payload);
122
123 /* callback method of FdPollItemIf */
124 virtual void processPollEvent(FdPollEventMask mask);
125
126 virtual void invokeAfterSocketCreationFunc() const;
127
128 private:
129 ConnectionManager& getConnectionManager() const;
130 void removeFrontOutstandingSend();
131 bool mInWritable;
132 bool mFlowTimerEnabled;
133 FdPollItemHandle mPollItemHandle;
134
136 Connection();
137
139 Connection(const Connection&);
140 Connection& operator=(const Connection&);
141 bool mIsServer;
142};
143
146
147}
148
149#endif
150/* ====================================================================
151 * The Vovida Software License, Version 1.0
152 *
153 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
154 * Copyright (c) 2000
155 *
156 * Redistribution and use in source and binary forms, with or without
157 * modification, are permitted provided that the following conditions
158 * are met:
159 *
160 * 1. Redistributions of source code must retain the above copyright
161 * notice, this list of conditions and the following disclaimer.
162 *
163 * 2. Redistributions in binary form must reproduce the above copyright
164 * notice, this list of conditions and the following disclaimer in
165 * the documentation and/or other materials provided with the
166 * distribution.
167 *
168 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
169 * and "Vovida Open Communication Application Library (VOCAL)" must
170 * not be used to endorse or promote products derived from this
171 * software without prior written permission. For written
172 * permission, please contact vocal@vovida.org.
173 *
174 * 4. Products derived from this software may not be called "VOCAL", nor
175 * may "VOCAL" appear in their name, without prior written
176 * permission of Vovida Networks, Inc.
177 *
178 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
179 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
180 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
181 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
182 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
183 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
184 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
185 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
186 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
187 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
188 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
189 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
190 * DAMAGE.
191 *
192 * ====================================================================
193 *
194 * This software consists of voluntary contributions made by Vovida
195 * Networks, Inc. and many individuals on behalf of Vovida Networks,
196 * Inc. For more information on Vovida Networks, Inc., please see
197 * <http://www.vovida.org/>.
198 *
199 */
#define max(x, y)
Heritable intrusive doubly linked list element templates.
Handles cross-platform sockets compatibility.
virtual Transport * transport() const
Collection of Connection per Transport.
Connection implements, via sockets, ConnectionBase for managed connections.
Socket getSocket() const
virtual int read(char *, const int)
pure virtual, but need concrete Connection for book-ends of lists
int performWrite()
send some or all of a queued data; remove from writable if completely written
bool performWrites(unsigned int max=0)
Call performWrite() repeatedly, until either the send queue is exhausted, the write() call fails (pro...
virtual void onWsClose(const Data &payload)
virtual bool checkConnectionTimedout()
virtual ~Connection()
virtual bool hasDataToRead()
always true – always add to fdset as read ready
virtual void onWsPing(const Data &payload)
bool mFirstWriteAfterConnectedPending
virtual bool isGood()
has valid connection
virtual bool isWritable()
virtual void onDoubleCRLF()
void enableFlowTimer()
Ensures this connection is in the FlowTimer LRU list in the connection manager.
virtual void invokeAfterSocketCreationFunc() const
bool isServer() const
void requestWrite(SendData *sendData)
queue data to write and add this to writable list
virtual void onSingleCRLF()
friend EncodeStream & operator<<(EncodeStream &strm, const resip::Connection &c)
static volatile bool mEnablePostConnectSocketFuncCall
virtual void processPollEvent(FdPollEventMask mask)
Virtual function of FdPollItemIf, called to process io events.
static void setEnablePostConnectSocketFuncCall(bool enabled=true)
bool performReads(unsigned int max=0)
Call read() repeatedly, until an error occurs (because the fd is not ready to read,...
virtual int write(const char *, const int)
pure virtual, but need concrete Connection for book-ends of lists
void ensureWritable()
ensure that we are on the writeable list if required
virtual bool transportWrite()
int read()
move data from the connection to the buffer; move this to front of least recently used list.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static void setEnablePostConnectSocketFuncCall(bool enabled=true)
The base class for Transport classes.
Definition Transport.hxx:83
Represents a network address.
Definition Tuple.hxx:59
FlowKey mFlowKey
This is a (largely) opaque key that subclasses of Transport will use to help record/find flows.
Definition Tuple.hxx:189
dcm! – add UnusedChecking(_enum) below;
unsigned short FdPollEventMask
Definition FdPoll.hxx:28
IntrusiveListElement2< Connection * > ConnectionWriteList
IntrusiveListElement3< Connection * > FlowTimerLruList
int Socket
Definition Socket.hxx:94
struct FdPollItemFake * FdPollItemHandle
This is opaque type used to identify a particular Item.
Definition FdPoll.hxx:42
IntrusiveListElement1< Connection * > ConnectionReadList
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
IntrusiveListElement< Connection * > ConnectionLruList
three intrusive list types for in-place reference
#define EncodeStream
void list()
Definition userAdmin.cxx:66