moss-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Moss-devel] CVS: moss/rmc/src/Transport/Socket Makefile.am,NONE,1.1 Tra


From: Alexander Feder <address@hidden>
Subject: [Moss-devel] CVS: moss/rmc/src/Transport/Socket Makefile.am,NONE,1.1 TransportClientSocket.cxx,NONE,1.1 TransportServerSocket.cxx,NONE,1.1
Date: Sun, 23 Jun 2002 09:27:52 -0400

Update of /cvsroot/moss/moss/rmc/src/Transport/Socket
In directory subversions:/tmp/cvs-serv2212/src/Transport/Socket

Added Files:
        Makefile.am TransportClientSocket.cxx 
        TransportServerSocket.cxx 
Log Message:
added rmc


--- NEW FILE ---
SUBDIRS = .
lib_LTLIBRARIES    = libRMCTransportServerSocket.la 
libRMCTransportClientSocket.la

CXXFLAGS = -Wall -g -O2

INCLUDES=-I../../../include

libRMCTransportServerSocket_la_LDFLAGS = --export-dynamic
libRMCTransportServerSocket_la_SOURCES = TransportServerSocket.cxx
libRMCTransportServerSocket_la_LIBADD = ../libRMCTransportServer.la \
                                        ../libRMCTransportClientHandler.la
#                                        ../../family/Socket/libSocket.la \
#                                        ../../family/Socket/libSocketNamed.la \
#                                        ../../family/Socket/libSocketUnNamed.la

libRMCTransportClientSocket_la_LDFLAGS = --export-dynamic
libRMCTransportClientSocket_la_SOURCES = TransportClientSocket.cxx
libRMCTransportClientSocket_la_LIBADD = ../libRMCTransportClient.la
#                                        ../../family/Socket/libSocket.la \
#                                        ../../family/Socket/libSocketUnNamed.la

--- NEW FILE ---
/***************************************************************************
                        TransportClientSocket.cxx
                           -------------------
    begin                : Thu June 7 2001
    copyright            : (C) 2001 by Alexander Feder
    email                : address@hidden

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *                                                                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place Suite 330,                                            *
 *   Boston, MA  02111-1307, USA.                                          *
 *                                                                         *
 ***************************************************************************/

#include "generic.h"
#include "Transport/TransportClientSocket.h"
#include "Transport/SocketUnNamed.h"

using namespace rmc;
using namespace family;

#ifdef WIN32
  bool CSocket::s_bWinSocketOk = CSocket::WinSocketInitialize();
#endif // WIN32

CTransportClientSocket CTransportClientSocket::s_oSocketClient;

extern "C"
  {
  CTransportClientSocket* GetTransport()
    {
    return &CTransportClientSocket::s_oSocketClient;
    } // CTransportClientSocket* GetTransport()
  }; // extern "C"

/***************************************************************************
 *
 *  Construction/Destruction
 *
 */

CTransportClientSocket::CTransportClientSocket ( )
    :CTransportClient()
  {
  Initialize();
  } // CTransportClient::CTransportClient ( )

CTransportClientSocket::~CTransportClientSocket ( )
  {
  delete m_poTransportBufferClient;
  m_poTransportBufferClient = 0;
  }

 /***************************************************************************
  *
  *  public Methods
  *
  */

LONG CTransportClientSocket::RemoteSystemConfig (const string& sComputer,
                                                 const string& sLogin,
                                                 const string& sPassword)
  {
  string::size_type nPos = sComputer.find(':');
  if (nPos == string::npos)
    {
    //+ please any more selfspeaking name here
    return -3; // INVALID ADDRESS!
    }

  m_sAddress = sComputer.substr(0, nPos);
  string sPort(sComputer.substr(nPos +1));

  m_nPort = atoi(sPort.c_str());
  if (m_nPort == 0)
    {
    //+ please any more selfspeaking name here
    return -3; // INVALID ADDRESS!
    }

  return CTransportClient::RemoteSystemConfig(sComputer,sLogin,sPassword);
  } // LONG CTransportClientSocket::RemoteSystemConfig (const string& 
sComputer,..


void CTransportClientSocket::Initialize ( )
  {
  m_nPort                   = 0;
  m_poTransportBufferClient = 0;
  } // void CTransportClientSocket::Initialize ( )


/***************************************************************************
 *
 *  protected Methods
 *
 */

LONG CTransportClientSocket::Connect ( )
  {
  TRACE("CTransportClientSocket::Connect()\n")

  // we delete it, if any value is assigned
  delete m_poTransportBufferClient;
  m_poTransportBufferClient = 0;

  CSocketUnNamed *poSocket  = new CSocketUnNamed();
  m_poTransportBufferClient = poSocket;

  LONG nResult = poSocket->Connect(m_sAddress, m_nPort);

  return (nResult <= 0) ? -1 : 0;
  } // LONG CTransportClientSocket::Connect ( )

--- NEW FILE ---
/***************************************************************************
                        TransportServerSocket.cxx
                           -------------------
    begin                : Thu June 7 2001
    copyright            : (C) 2001 by Alexander Feder
    email                : address@hidden

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *                                                                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place Suite 330,                                            *
 *   Boston, MA  02111-1307, USA.                                          *
 *                                                                         *
 ***************************************************************************/

#include "generic.h"
#include "Transport/TransportServerSocket.h"
#include "Transport/SocketNamed.h"


using namespace rmc;
using namespace family;

#ifdef WIN32
  bool CSocket::s_bWinSocketOk = CSocket::WinSocketInitialize();
#endif // WIN32

// 2001.11.29 - morgner
// CTransportServerSocket *g_poTransportServerSocket = new 
CTransportServerSocket(6666);
CTransportServer *CTransportServerSocket::s_poTransport = new 
CTransportServerSocket();

extern "C"
    {
    void RegisterRmcServer ( CRmcServer *poRmcServer );
    }

/***************************************************************************
 *
 *  Construction/Destruction
 *
 */

CTransportServerSocket::CTransportServerSocket (int nPort)
    : CTransportServer()
  {
  TRACE("CTransportServerSocket::CTransportServerSocket\n")

  m_poSocketServer = new CSocketNamed();
  ((CSocketNamed*)m_poSocketServer)->Bind(nPort);

  // Manfred Morgner: 15.11.2001
  // we will use the default parameter of the methode,
  // because we have no reason to do anything other
  ((CSocketNamed*)m_poSocketServer)->Listen( /* 32 */ );
  TRACE("Returned from m_poSocketServer.Listen(..)\n")

  } // CTransportServerSocket::CTransportServerSocket (int nPrt)

CTransportServerSocket::~CTransportServerSocket ( )
  {
  TRACE("CTransportServerSocket Destructor\n")
  } // CTransportServerSocket::~CTransportServerSocket ( )

/***************************************************************************
 *
 *  public Methods
 *
 */


int CTransportServerSocket::WaitForClient ( )
  {
  TRACE("CTransportServerSocket::WaitForCLient\n")

  while (1)
    {
    // should become the unnamed interface ???
    // createTransport()
    // getTransport()
    // ....
    CSocketUnNamed* poSocketClient = ((CSocketNamed 
*)m_poSocketServer)->WaitForClient();
    if ( poSocketClient == 0 )
      {
      break;
      }
    // one ClientHandler per socket
    CClientHandler* poClientHandler = new CClientHandler ( poSocketClient, 
m_poRmcServer );
    TRACE("whats up?\n")
    poClientHandler->Start();
/*
    m_moSocket2Client[poSocketClient->FdGet()] = new CClientHandler ( 
poSocketClient, &m_poRmcServer );
    m_moSocket2Client[poSocketClient->FdGet()]->Start();
*/
    TRACE("Got a Client..\n")

        } // while (1)

  return 0;
  }; // int CTransportServerSocket::WaitForClient ( )

/***************************************************************************
 *
 *  protected Methods
 *
 */

void CTransportServerSocket::RemoveAllClients()
  {
  while ( !m_moSocket2Client.empty() )
    {
    RemoveClient( m_moSocket2Client.begin()->first );
    } // while ( !m_moSocket2Client.empty() )
  } // void CTransportServerSocket::RemoveAllClients()

void CTransportServerSocket::RemoveClient(int fd)
  {
  CMapSocket2Client::iterator it = m_moSocket2Client.find(fd);

  if (it == m_moSocket2Client.end() )
    {
    return;
    } // if (it == m_moSocket2Client.end() )

// ?? what is with the "fd" in "it" ?

  m_moSocket2Client.erase(it);

  } // void CTransportServerSocket::RemoveClient(int fd)


/***************************************************************************
 *
 *  private methods
 *
 */


// this export (the only export for this library) gets the
// address of the object that loaded this library and is
// interested in the service of it
extern "C"
  {
  void RegisterRmcServer ( CRmcServer *poRmcServer )
    {
    CTransportServerSocket::s_poTransport->RegisterRmcServer(poRmcServer);
    } // void RegisterRmcServer ( CRmcServer *poRmcServer )
  } // extern "C"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]