sipxportlib  Version 3.3
OsConnectionSocket.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _OsConnectionSocket_h_
13 #define _OsConnectionSocket_h_
14 
15 // SYSTEM INCLUDES
16 //#include <...>
17 
18 // APPLICATION INCLUDES
19 #include <os/OsSocket.h>
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 // FORWARD DECLARATIONS
29 class UtlSList;
30 
31 //: Implements TCP version of OsSocket
32 // This class provides the implementation of the TCP datagram
33 // based socket class which may be instantiated.
35 {
36 /* //////////////////////////// PUBLIC //////////////////////////////////// */
37 public:
38 
39 /* ============================ CREATORS ================================== */
40 
42  const char* remoteHostName,
44  const char* localIp = NULL,
45  const bool bConnect = true);
46 
47  OsConnectionSocket(int connectedSocketDescriptor);
48 
49  OsConnectionSocket(const char* localIp,
50  int connectedSocketDescriptor);
51 
52  virtual
54  //:Destructor
55 
56 /* ============================ MANIPULATORS ============================== */
57 
58  virtual int connect();
59  //: Sets up the initial connection with the server
60 
61  virtual UtlBoolean reconnect();
62  //: Sets up the connection again, assuming the connection failed
63 
64  virtual int read(char* buffer, int bufferLength);
65  //:Blocking read from the socket
66  // Read bytes into the buffer from the socket up to a maximum of
67  // bufferLength bytes. This method will block until there is
68  // something to read from the socket.
72 
73  virtual int read(char* buffer, int bufferLength,
74  UtlString* ipAddress, int* port);
75  //:Blocking read from the socket
76  // Read bytes into the buffer from the socket up to a maximum of
77  // bufferLength bytes. This method will block until there is
78  // something to read from the socket.
84 
85  virtual int read(char* buffer, int bufferLength, long waitMilliseconds);
86  //: Non-blocking or limited blocking read from socket
87  // Same as blocking version except that this read will block
88  // for no more than the specified length of time.
90 
91 /* ============================ ACCESSORS ================================= */
93  //: Returns the protocol type of this socket
94 
95 
96 /* ============================ INQUIRY =================================== */
97 
99  virtual bool isEncrypted() const;
100 
102  virtual bool peerIdentity( UtlSList* altNames = NULL
106  ,UtlString* commonName = NULL
107  ) const;
118 /* //////////////////////////// PROTECTED ///////////////////////////////// */
119 protected:
120  bool initialize(const char* serverName, int serverPort, UtlBoolean blockingConnect);
121 
122 /* //////////////////////////// PRIVATE /////////////////////////////////// */
123 private:
124 
125  struct sockaddr_in serverSockAddr;
126 
127  OsConnectionSocket(const OsConnectionSocket& rOsConnectionSocket);
128  //:Disable copy constructor
129 
130  OsConnectionSocket();
131  //:Disable default constructor
132 
133  OsConnectionSocket& operator=(const OsConnectionSocket& rhs);
134  //:Assignment operator
135 
136 };
137 
138 /* ============================ INLINE METHODS ============================ */
139 
140 #endif // _OsConnectionSocket_h_
141 
Definition: OsSocket.h:79
IpProtocolSocketType
Definition: OsSocket.h:92
virtual int read(char *buffer, int bufferLength)
param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero...
Definition: OsConnectionSocket.cpp:304
virtual void makeBlocking()
Definition: OsSocket.cpp:776
virtual int connect()
Definition: OsConnectionSocket.cpp:273
#define NULL
Definition: UtlDefs.h:29
virtual ~OsConnectionSocket()
Definition: OsConnectionSocket.cpp:153
virtual bool isEncrypted() const
Is this connection encrypted using TLS/SSL?
Definition: OsConnectionSocket.cpp:347
virtual UtlBoolean reconnect()
Definition: OsConnectionSocket.cpp:295
Definition: UtlString.h:48
virtual OsSocket::IpProtocolSocketType getIpProtocol() const
param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero in whi...
Definition: OsConnectionSocket.cpp:340
Definition: UtlSList.h:47
Definition: OsConnectionSocket.h:34
int UtlBoolean
Definition: UtlDefs.h:41
#define TRUE
Definition: UtlDefs.h:25
bool initialize(const char *serverName, int serverPort, UtlBoolean blockingConnect)
Definition: OsConnectionSocket.cpp:159
int remoteHostPort
Definition: OsSocket.h:322
virtual bool peerIdentity(UtlSList *altNames=NULL, UtlString *commonName=NULL) const
Get any authenticated peer host names.
Definition: OsConnectionSocket.cpp:354
UtlString remoteHostName
Definition: OsSocket.h:325