|
From: Marek P. <ma...@us...> - 2001-08-12 07:35:35
|
Update of /cvsroot/javaprofiler/library/src/commun
In directory usw-pr-cvs1:/tmp/cvs-serv724/src/commun
Modified Files:
communSocket.cpp communSocket.h iprof.cpp
Log Message:
changes in library setups; now, library can run in server or client mode
(java part not implemented yet)
Index: communSocket.cpp
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/commun/communSocket.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** communSocket.cpp 2001/08/09 23:22:55 1.4
--- communSocket.cpp 2001/08/12 07:35:31 1.5
***************
*** 1,7 ****
#include "../main/includes.h"
! CommunSocket::CommunSocket( int listenMode, const String& hostname,
! unsigned short port) :
! _listenMode( listenMode),
_hostname( hostname),
_port( port),
--- 1,7 ----
#include "../main/includes.h"
! CommunSocket::CommunSocket( int connectMode, const String& hostname, unsigned short port) :
!
! _connectMode( connectMode),
_hostname( hostname),
_port( port),
***************
*** 14,18 ****
if( _failed = ((_sock = socket( AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)) return;
! if( _listenMode) {
_csock = _sock;
--- 14,18 ----
if( _failed = ((_sock = socket( AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)) return;
! if( _connectMode) { // client
_csock = _sock;
***************
*** 31,35 ****
if( _failed = ((_sock = socket( PF_INET, SOCK_STREAM, 0)) < 0)) return;
! if( _listenMode) {
_csock = _sock;
--- 31,35 ----
if( _failed = ((_sock = socket( PF_INET, SOCK_STREAM, 0)) < 0)) return;
! if( _connectMode) { // client
_csock = _sock;
***************
*** 52,56 ****
#ifdef WIN32
! if( !_listenMode) {
shutdown( _sock, SD_BOTH);
--- 52,56 ----
#ifdef WIN32
! if( !_connectMode) { // server
shutdown( _sock, SD_BOTH);
***************
*** 64,68 ****
#else
! if( !_listenMode) {
shutdown( _sock, SHUT_RDWR);
--- 64,68 ----
#else
! if( !_connectMode) { // server
shutdown( _sock, SHUT_RDWR);
***************
*** 81,89 ****
int csize = sizeof( cin);
! if( !_listenMode) {
! if( _failed = ((_csock = accept( _sock, (sockaddr*)&cin, &csize)) == INVALID_SOCKET)) return 0;
}
! else {
cin.sin_family = AF_INET;
--- 81,89 ----
int csize = sizeof( cin);
! if( !_connectMode) { // server
! _failed = ((_csock = accept( _sock, (sockaddr*)&cin, &csize)) == INVALID_SOCKET);
}
! else { // client
cin.sin_family = AF_INET;
***************
*** 95,99 ****
cin.sin_addr.s_addr = (unsigned)atol( h->h_addr_list[0]);
! if( _failed = (connect( _csock, (sockaddr*)&cin, csize) == SOCKET_ERROR)) return 0;
}
#else
--- 95,99 ----
cin.sin_addr.s_addr = (unsigned)atol( h->h_addr_list[0]);
! _failed = (connect( _csock, (sockaddr*)&cin, csize) == SOCKET_ERROR);
}
#else
***************
*** 101,109 ****
socklen_t csize = sizeof( cin);
! if( !_listenMode) {
! if( _failed = ((_csock = accept( _sock, (sockaddr*)&cin, &csize)) < 0)) return 0;
}
! else {
cin.sin_family = AF_INET;
--- 101,109 ----
socklen_t csize = sizeof( cin);
! if( !_connectMode) { // server
! _failed = ((_csock = accept( _sock, (sockaddr*)&cin, &csize)) < 0);
}
! else { // client
cin.sin_family = AF_INET;
***************
*** 115,123 ****
cin.sin_addr.s_addr = (unsigned)atol( h->h_addr_list[0]);
! if( _failed = (connect( _csock, (sockaddr*)&cin, csize) < 0)) return 0;
}
#endif
! return 1;
}
--- 115,123 ----
cin.sin_addr.s_addr = (unsigned)atol( h->h_addr_list[0]);
! _failed = (connect( _csock, (sockaddr*)&cin, csize) < 0);
}
#endif
! return !_failed;
}
Index: communSocket.h
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/commun/communSocket.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** communSocket.h 2001/08/09 23:22:55 1.4
--- communSocket.h 2001/08/12 07:35:31 1.5
***************
*** 4,12 ****
/** Socket communication. This class implements TCP/IP socket
** communication and offers the user of this class the standard
! ** interface of Commun class. Implementation is system dependend
** (so it is different on WIN32 and UNIX systems). This class
! ** stands a server out.
**
! ** @see Commun
**
** @author Marek Przeczek */
--- 4,12 ----
/** Socket communication. This class implements TCP/IP socket
** communication and offers the user of this class the standard
! ** interface of Commun class. Implementation is system dependent
** (so it is different on WIN32 and UNIX systems). This class
! ** stands a server or client out.
**
! ** @see CommunShMem, Commun
**
** @author Marek Przeczek */
***************
*** 28,51 ****
#endif
! /// hostname (if listenMode is on)
String _hostname;
- /// port number
unsigned short _port;
! /// listening connector mode (1 = on, 0 = off)
! int _listenMode;
public:
! /** Constructor. It initializes server
! ** on given port.
**
! ** @param listenMode listening connector mode
! ** @param hostname hostname (if listenMode is on)
** @param port port number */
! CommunSocket( int listenMode, const String& hostname,
! unsigned short port);
/** Destructor. It stops communication and
--- 28,58 ----
#endif
! /** Hostname. It is used only when connectMode is set
! ** to 'client' (1); it contains target host's name. */
!
String _hostname;
+
+ /** Port number. When connectMode is set to 'server' (0),
+ ** it contains port number, where server listens for new
+ ** connections; when connectMode is set to 'client' (1),
+ ** it contains target host's port number. */
unsigned short _port;
! /// connect mode (0 = server, 1 = client)
! int _connectMode;
public:
! /** Constructor. It initializes server for listening
! ** on given port (if connectMode is set to 'server').
! ** If connectMode is set to 'client', this class connects
! ** to the target specified by hostname and port arguments.
**
! ** @param connectMode mode (0 = as server, 1 = as client)
! ** @param hostname target host (if connectMode is set to 'client')
** @param port port number */
! CommunSocket( int connectMode, const String& hostname, unsigned short port);
/** Destructor. It stops communication and
Index: iprof.cpp
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/commun/iprof.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** iprof.cpp 2001/08/09 23:22:55 1.4
--- iprof.cpp 2001/08/12 07:35:31 1.5
***************
*** 22,31 ****
if( setup.com.communType == COMMUN_SOCKET)
!
! _commun = new CommunSocket( setup.com.listenMode,
setup.com.hostname,
setup.com.port);
! else _commun = new CommunShMem( setup.com.shmemStr, setup.com.shmemSize);
}
--- 22,31 ----
if( setup.com.communType == COMMUN_SOCKET)
!
! _commun = new CommunSocket( setup.com.connectMode,
setup.com.hostname,
setup.com.port);
! else _commun = new CommunShMem( setup.com.shmemId, setup.com.shmemSize);
}
|