Classes | Public Member Functions | Private Types | Private Attributes | List of all members
FIX::SocketServer Class Reference

Listens for and accepts incoming socket connections on a port. More...

#include <SocketServer.h>

Collaboration diagram for FIX::SocketServer:
Collaboration graph
[legend]

Classes

class  Strategy
 

Public Member Functions

 SocketServer (int timeout=0)
 
int add (int port, bool reuse=false, bool noDelay=false, int sendBufSize=0, int rcvBufSize=0) throw ( SocketException& )
 
int accept (int socket)
 
void close ()
 
bool block (Strategy &strategy, bool poll=0, double timeout=0.0)
 
size_t numConnections ()
 
SocketMonitorgetMonitor ()
 
int socketToPort (int socket)
 
int portToSocket (int port)
 

Private Types

typedef std::map< int, SocketInfoSocketToInfo
 
typedef std::map< int, SocketInfoPortToInfo
 

Private Attributes

SocketToInfo m_socketToInfo
 
PortToInfo m_portToInfo
 
SocketMonitor m_monitor
 

Detailed Description

Listens for and accepts incoming socket connections on a port.

Definition at line 73 of file SocketServer.h.

Member Typedef Documentation

◆ PortToInfo

typedef std::map<int, SocketInfo> FIX::SocketServer::PortToInfo
private

Definition at line 96 of file SocketServer.h.

◆ SocketToInfo

typedef std::map<int, SocketInfo> FIX::SocketServer::SocketToInfo
private

Definition at line 94 of file SocketServer.h.

Constructor & Destructor Documentation

◆ SocketServer()

FIX::SocketServer::SocketServer ( int  timeout = 0)

Definition at line 111 of file SocketServer.cpp.

Member Function Documentation

◆ accept()

int FIX::SocketServer::accept ( int  socket)

Definition at line 138 of file SocketServer.cpp.

138 {
139  SocketToInfo::iterator i = m_socketToInfo.begin();
140  for( ; i != m_socketToInfo.end(); ++i )
141  {
142  int s = i->first;
143  socket_close( s );
144  socket_invalidate( s );
145  }
146 }
147 
148 bool SocketServer::block( Strategy& strategy, bool poll, double timeout )
149 {
150  std::set<int> sockets;
151  SocketToInfo::iterator i = m_socketToInfo.begin();
152  for( ; i != m_socketToInfo.end(); ++i )

References m_socketToInfo, FIX::socket_close(), and FIX::socket_invalidate().

◆ add()

int FIX::SocketServer::add ( int  port,
bool  reuse = false,
bool  noDelay = false,
int  sendBufSize = 0,
int  rcvBufSize = 0 
)
throw (SocketException &
)

Definition at line 114 of file SocketServer.cpp.

122 {
123  SocketInfo info = m_socketToInfo[socket];
124 
125  int result = socket_accept( socket );
126  if( info.m_noDelay )
127  socket_setsockopt( result, TCP_NODELAY );
128  if( info.m_sendBufSize )
129  socket_setsockopt( result, SO_SNDBUF, info.m_sendBufSize );
130  if( info.m_rcvBufSize )
131  socket_setsockopt( result, SO_RCVBUF, info.m_rcvBufSize );
132  if ( result >= 0 )
133  m_monitor.addConnect( result );
134  return result;
135 }
136 

◆ block()

bool FIX::SocketServer::block ( Strategy strategy,
bool  poll = 0,
double  timeout = 0.0 
)

Definition at line 165 of file SocketServer.cpp.

165 {
166  SocketToInfo::iterator find = m_socketToInfo.find( socket );
167  if( find == m_socketToInfo.end() ) return 0;
168  return find->second.m_port;
169 }
170 
171 int SocketServer::portToSocket( int port )
172 {
173  SocketToInfo::iterator find = m_portToInfo.find( port );
174  if( find == m_portToInfo.end() ) return 0;
175  return find->second.m_socket;
176 }
177 }

References m_socketToInfo.

◆ close()

void FIX::SocketServer::close ( )

Definition at line 154 of file SocketServer.cpp.

◆ getMonitor()

SocketMonitor& FIX::SocketServer::getMonitor ( )
inline

◆ numConnections()

size_t FIX::SocketServer::numConnections ( )
inline

Definition at line 86 of file SocketServer.h.

87 {

◆ portToSocket()

int FIX::SocketServer::portToSocket ( int  port)

Definition at line 188 of file SocketServer.cpp.

◆ socketToPort()

int FIX::SocketServer::socketToPort ( int  socket)

Definition at line 181 of file SocketServer.cpp.

Member Data Documentation

◆ m_monitor

SocketMonitor FIX::SocketServer::m_monitor
private

Definition at line 100 of file SocketServer.h.

◆ m_portToInfo

PortToInfo FIX::SocketServer::m_portToInfo
private

Definition at line 99 of file SocketServer.h.

◆ m_socketToInfo

SocketToInfo FIX::SocketServer::m_socketToInfo
private

Definition at line 98 of file SocketServer.h.

Referenced by accept(), and block().


The documentation for this class was generated from the following files:
FIX::SocketServer::m_monitor
SocketMonitor m_monitor
Definition: SocketServer.h:100
FIX::socket_setsockopt
int socket_setsockopt(int s, int opt)
Definition: Utility.cpp:225
FIX::SocketServer::block
bool block(Strategy &strategy, bool poll=0, double timeout=0.0)
Definition: SocketServer.cpp:165
FIX::SocketMonitor::addConnect
bool addConnect(int socket)
Definition: SocketMonitor.cpp:82
FIX::SocketServer::portToSocket
int portToSocket(int port)
Definition: SocketServer.cpp:188
FIX::SocketServer::m_portToInfo
PortToInfo m_portToInfo
Definition: SocketServer.h:99
FIX::socket_accept
int socket_accept(int s)
Definition: Utility.cpp:181
FIX::SocketServer::m_socketToInfo
SocketToInfo m_socketToInfo
Definition: SocketServer.h:98
FIX::socket_invalidate
void socket_invalidate(int &socket)
Definition: Utility.cpp:312
FIX::socket_close
void socket_close(int s)
Definition: Utility.cpp:197

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001