Logo Search packages:      
Sourcecode: sbnc version File versions  Download package

RESULT< bool > CCore::AddAdditionalListener ( unsigned short  Port,
const char *  BindAddress = NULL,
bool  SSL = false 
)

AddAdditionalListener

Creates an additional socket listener.

Parameters:
Port the port for the listener
BindAddress bind address (can be NULL)
SSL whether to use SSL

Definition at line 2185 of file Core.cpp.

References additionallistener_s::BindAddress, GetSSLContext(), additionallistener_s::Listener, additionallistener_s::ListenerV6, Log(), m_AdditionalListeners, additionallistener_s::Port, additionallistener_s::SSL, and UpdateAdditionalListeners().

Referenced by InitializeAdditionalListeners(), and CClientConnection::ProcessBncCommand().

                                                                                                {
      additionallistener_t AdditionalListener;
      CClientListener *Listener, *ListenerV6;

      for (unsigned int i = 0; i < m_AdditionalListeners.GetLength(); i++) {
            if (m_AdditionalListeners[i].Port == Port) {
                  THROW(bool, Generic_Unknown, "This port is already in use.");
            }
      }

      if (GetSSLContext() == NULL) {
            THROW(bool, Generic_Unknown, "Failed to create an SSL listener because there is no SSL server certificate.");
      }

      Listener = new CClientListener(Port, NULL, BindAddress, AF_INET, SSL);

      if (Listener == NULL || !Listener->IsValid()) {
            delete Listener;

            if (SSL) {
                  Log("Failed to create additional SSL listener on port %d.", Port);
                  THROW(bool, Generic_OutOfMemory, "Failed to create additional SSL listener on that port.");
            } else {
                  Log("Failed to create additional listener on port %d.", Port);
                  THROW(bool, Generic_OutOfMemory, "Failed to create additional listener on that port.");
            }
      }

      ListenerV6 = new CClientListener(Port, NULL, BindAddress, AF_INET6, SSL);

      if (ListenerV6 == NULL || !ListenerV6->IsValid()) {
            delete ListenerV6;
            ListenerV6 = NULL;
      }

      AdditionalListener.Port = Port;

      if (BindAddress != NULL) {
            AdditionalListener.BindAddress = strdup(BindAddress);
      } else {
            AdditionalListener.BindAddress = NULL;
      }

      AdditionalListener.SSL = SSL;
      AdditionalListener.Listener = Listener;
      AdditionalListener.ListenerV6 = ListenerV6;

      m_AdditionalListeners.Insert(AdditionalListener);

      UpdateAdditionalListeners();

      if (!SSL) {
            Log("Created additional listener on port %d.", Port);
      } else {
            Log("Created additional SSL listener on port %d.", Port);
      }

      RETURN(bool, true);
}


Generated by  Doxygen 1.6.0   Back to index