コード例 #1
0
void ThreadedSocketAcceptor::onInitialize( const SessionSettings& s )
throw ( RuntimeError )
{
  short port = 0;
  std::set<int> ports;

  std::set<SessionID> sessions = s.getSessions();
  std::set<SessionID>::iterator i = sessions.begin();
  for( ; i != sessions.end(); ++i )
  {
    const Dictionary& settings = s.get( *i );
    port = (short)settings.getInt( SOCKET_ACCEPT_PORT );

    m_portToSessions[port].insert( *i );

    if( ports.find(port) != ports.end() )
      continue;
    ports.insert( port );

    const bool reuseAddress = settings.has( SOCKET_REUSE_ADDRESS ) ? 
      settings.getBool( SOCKET_REUSE_ADDRESS ) : true;

    const bool noDelay = settings.has( SOCKET_NODELAY ) ? 
      settings.getBool( SOCKET_NODELAY ) : false;

    const int sendBufSize = settings.has( SOCKET_SEND_BUFFER_SIZE ) ?
      settings.getInt( SOCKET_SEND_BUFFER_SIZE ) : 0;

    const int rcvBufSize = settings.has( SOCKET_RECEIVE_BUFFER_SIZE ) ?
      settings.getInt( SOCKET_RECEIVE_BUFFER_SIZE ) : 0;

    int socket = socket_createAcceptor( port, reuseAddress );
    if( socket < 0 )
    {
      SocketException e;
      socket_close( socket );
      throw RuntimeError( "Unable to create, bind, or listen to port " 
                         + IntConvertor::convert( (unsigned short)port ) + " (" + e.what() + ")" );
    }
    if( noDelay )
      socket_setsockopt( socket, TCP_NODELAY );
    if( sendBufSize )
      socket_setsockopt( socket, SO_SNDBUF, sendBufSize );
    if( rcvBufSize )
      socket_setsockopt( socket, SO_RCVBUF, rcvBufSize );

    m_socketToPort[socket] = port;
    m_sockets.insert( socket );
  }    
}
コード例 #2
0
void ThreadedSSLSocketInitiator::onConfigure(const SessionSettings &s) throw(
    ConfigError)
{
  const Dictionary &dict = s.get();

  if (dict.has(RECONNECT_INTERVAL))
    m_reconnectInterval = dict.getInt(RECONNECT_INTERVAL);
  if (dict.has(SOCKET_NODELAY))
    m_noDelay = dict.getBool(SOCKET_NODELAY);
  if (dict.has(SOCKET_SEND_BUFFER_SIZE))
    m_sendBufSize = dict.getInt(SOCKET_SEND_BUFFER_SIZE);
  if (dict.has(SOCKET_RECEIVE_BUFFER_SIZE))
    m_rcvBufSize = dict.getInt(SOCKET_RECEIVE_BUFFER_SIZE);
}
コード例 #3
0
void ThreadedSocketAcceptor::onConfigure( const SessionSettings& s )
throw ( ConfigError )
{
  std::set<SessionID> sessions = s.getSessions();
  std::set<SessionID>::iterator i;
  for( i = sessions.begin(); i != sessions.end(); ++i )
  {
    const Dictionary& settings = s.get( *i );
    settings.getInt( SOCKET_ACCEPT_PORT );
    if( settings.has(SOCKET_REUSE_ADDRESS) )
      settings.getBool( SOCKET_REUSE_ADDRESS );
    if( settings.has(SOCKET_NODELAY) )
      settings.getBool( SOCKET_NODELAY );
  }
}
コード例 #4
0
ファイル: HttpServer.cpp プロジェクト: BornCapital/quickfix
void HttpServer::startGlobal( const SessionSettings& s ) 
throw ( ConfigError, RuntimeError )
{
  Locker l( s_mutex );

  if( !s.get().has(HTTP_ACCEPT_PORT) )
    return;

  s_count += 1;
  if( !s_pServer )
  {
    s_pServer = new HttpServer( s );
    s_pServer->start();
  }
}
コード例 #5
0
ファイル: HttpServer.cpp プロジェクト: BornCapital/quickfix
void HttpServer::onConfigure( const SessionSettings& s )
throw ( ConfigError )
{  
  m_port = s.get().getLong( HTTP_ACCEPT_PORT );
}