sipxportlib  Version 3.3
OsServerSocket.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 
15 #ifndef _OsServerSocket_h_
16 #define _OsServerSocket_h_
17 
18 // SYSTEM INCLUDES
19 //#include <...>
20 
21 // APPLICATION INCLUDES
22 #include <os/OsConnectionSocket.h>
23 #include <os/OsAtomics.h>
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // TYPEDEFS
32 // FORWARD DECLARATIONS
33 
34 //: Implements TCP server for accepting TCP connections
35 // This class provides the implementation of the UDP datagram-based
36 // socket class which may be instantiated.
37 
39 {
40 /* //////////////////////////// PUBLIC //////////////////////////////////// */
41 public:
42 
43 /* ============================ CREATORS ================================== */
44 
45  OsServerSocket(int connectionQueueSize,
46  int serverPort=PORT_DEFAULT,
47  const char* szBindAddr = NULL,
48  const bool bPerformBind = true);
49 
50  //:Constructor to set up TCP socket server
51  // Sets the socket connection queue and starts listening on the
52  // port for requests to connect.
53  //
55  // connection requests which are allowed before subsequent requests
56  // are turned away.
58  // accept connection requests. PORT_DEFAULT means let OS pick port.
59 
61  //:Assignment operator
62 
63  virtual
65  //:Destructor
66 
67 
68 /* ============================ MANIPULATORS ============================== */
69 
70  virtual OsConnectionSocket* accept();
71  //:Blocking accept of next connection
72  // Blocks and waits for the next TCP connection request.
75 
76  virtual void close();
77  //: Close down the server
78 
79 /* ============================ ACCESSORS ================================= */
80 
81  virtual int getSocketDescriptor() const;
82  //:Return the socket descriptor
83  // Warning: Use of this method risks the creation of platform-dependent
84  // code.
85 
86  virtual int getLocalHostPort() const;
87  //:Return the local port number
88  // Returns the port to which this socket is bound on this host.
89 
90  virtual void getBindIp(UtlString& ip) const ;
91  //:Gets the bind ip (could be 0.0.0.0)
92 
93 /* ============================ INQUIRY =================================== */
94  virtual UtlBoolean isOk() const;
95  //: Server socket is in ready to accept incoming conection requests.
96 
97  int isConnectionReady();
98  //: Poll to see if connections are waiting
101 
102 /* //////////////////////////// PROTECTED ///////////////////////////////// */
103 protected:
104  virtual OsConnectionSocket* createConnectionSocket(UtlString localIp, int descriptor);
105 
109 
110 /* //////////////////////////// PRIVATE /////////////////////////////////// */
111 private:
112  OsServerSocket(const OsServerSocket& rOsServerSocket);
113  //:Disable copy constructor
114 
115  OsServerSocket();
116  //:Disable default constructor
117 
118 
119 };
120 
121 /* ============================ INLINE METHODS ============================ */
122 
123 #endif // _OsServerSocket_h_
124 
virtual OsConnectionSocket * createConnectionSocket(UtlString localIp, int descriptor)
returns: 1 if one or call to accept() will not block returns: 0 if no connections are ready (i...
Definition: OsServerSocket.cpp:286
OsAtomicLightInt socketDescriptor
Definition: OsServerSocket.h:106
int isConnectionReady()
int localHostPort
Definition: OsServerSocket.h:107
virtual UtlBoolean isOk() const
Definition: OsServerSocket.cpp:279
#define NULL
Definition: UtlDefs.h:29
OsAtomicLight< int > OsAtomicLightInt
Definition: OsAtomics.h:353
virtual void getBindIp(UtlString &ip) const
Definition: OsServerSocket.cpp:272
virtual void close()
returns: Returns a socket connected to the client requesting the returns: connection. If an error occurs returns NULL.
Definition: OsServerSocket.cpp:234
Definition: UtlString.h:48
UtlString mLocalIp
Definition: OsServerSocket.h:108
virtual int getLocalHostPort() const
Definition: OsServerSocket.cpp:267
virtual OsConnectionSocket * accept()
Definition: OsServerSocket.cpp:205
Definition: OsConnectionSocket.h:34
int UtlBoolean
Definition: UtlDefs.h:41
Definition: OsServerSocket.h:38
#define PORT_DEFAULT
Definition: OsDefs.h:180
OsServerSocket & operator=(const OsServerSocket &rhs)
param: connectionQueueSize - The maximum number of outstanding
Definition: OsServerSocket.cpp:197
virtual ~OsServerSocket()
Definition: OsServerSocket.cpp:188
virtual int getSocketDescriptor() const
Definition: OsServerSocket.cpp:262