diff options
author | fcolin | 2007-02-01 13:04:56 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 13:04:56 +0000 |
commit | fa866b8d6ee2cd803508fbc2c70186913c056388 (patch) | |
tree | 08701d87a95d3008942a8af1e815af3219d794c2 /Bus/Ivy | |
parent | 2621f2e2f4c5b4f4158e6f6a417efe1cfaf98c60 (diff) | |
download | ivy-cplusplus-fa866b8d6ee2cd803508fbc2c70186913c056388.zip ivy-cplusplus-fa866b8d6ee2cd803508fbc2c70186913c056388.tar.gz ivy-cplusplus-fa866b8d6ee2cd803508fbc2c70186913c056388.tar.bz2 ivy-cplusplus-fa866b8d6ee2cd803508fbc2c70186913c056388.tar.xz |
Utilisateur : Fcolin Date : 31/01/01 Heure : 11:18 Archivé dans $/Ivy (vss 5)
Diffstat (limited to 'Bus/Ivy')
-rw-r--r-- | Bus/Ivy/ThreadedSocket.cxx | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/Bus/Ivy/ThreadedSocket.cxx b/Bus/Ivy/ThreadedSocket.cxx index 5f4c183..955af12 100644 --- a/Bus/Ivy/ThreadedSocket.cxx +++ b/Bus/Ivy/ThreadedSocket.cxx @@ -8,16 +8,13 @@ #include "ThreadedSocket.h"
-// Class CThreadedSocketException
-//IMPLEMENT_DYNAMIC(CThreadedSocketException, CException)
-
CThreadedSocketException::CThreadedSocketException(char* pchMessage)
{
m_strMessage = pchMessage;
m_nError = WSAGetLastError();
}
-bool CThreadedSocketException::GetErrorMessage(String & lpstrError, UINT nMaxError,
+bool CThreadedSocketException::GetErrorMessage(string & lpstrError, UINT nMaxError,
PUINT pnHelpContext /*= NULL*/)
{
lpstrError = m_strMessage;
@@ -77,7 +74,7 @@ void CThreadedSocket::Create(UINT nSocketPort, int nSocketType, -void CThreadedSocket::GetPeerName(String & rPeerAddress, UINT& rPeerPort)
+void CThreadedSocket::GetPeerName(string & rPeerAddress, UINT& rPeerPort)
{
SOCKADDR_IN sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr));
@@ -88,7 +85,7 @@ void CThreadedSocket::GetPeerName(String & rPeerAddress, UINT& rPeerPort) rPeerAddress = inet_ntoa(sockAddr.sin_addr);
}
-void CThreadedSocket::GetSockName(String & rSocketAddress, UINT& rSocketPort)
+void CThreadedSocket::GetSockName(string & rSocketAddress, UINT& rSocketPort)
{
SOCKADDR_IN sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr));
@@ -105,7 +102,7 @@ void CThreadedSocket::GetSockName(String & rSocketAddress, UINT& rSocketPort) void CThreadedSocket::Accept(CThreadedSocket& rConnectedSocket,
SOCKADDR* lpSockAddr, int* lpSockAddrLen)
{
- assert(rConnectedSocket.m_hSocket == INVALID_SOCKET);
+ ASSERT(rConnectedSocket.m_hSocket == INVALID_SOCKET);
SOCKET hTemp = accept(m_hSocket, lpSockAddr, lpSockAddrLen);
@@ -153,7 +150,7 @@ void CThreadedSocket::Close() if (m_hSocket != INVALID_SOCKET)
{
AsyncSelect(0);
- assert(SOCKET_ERROR != closesocket(m_hSocket));
+ ASSERT(SOCKET_ERROR != closesocket(m_hSocket));
m_hSocket = INVALID_SOCKET;
//WSASetEvent( m_hEventObject );
}
@@ -164,28 +161,28 @@ bool CThreadedSocket::Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen) if ( !connect(m_hSocket, lpSockAddr, nSockAddrLen) )
{
DWORD err = WSAGetLastError();
- if ( err == 0 ) return TRUE;
+ if ( err == 0 ) return true;
TRACE( "***************************************Error connect %d\n", err);
if ( err != WSAEWOULDBLOCK )
- return FALSE;
+ return false;
// Wait for connection to complete
TRACE( "***************************************Waiting for connection to complete\n");
- err = WSAWaitForMultipleEvents( 1, m_hEvent, FALSE, WSA_INFINITE, TRUE);
+ err = WSAWaitForMultipleEvents( 1, m_hEvent, false, WSA_INFINITE, true);
//TRACE( "Thread socket %d wait return %d\n", m_hSocket, err );
if ( err == WSA_WAIT_FAILED )
{
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
- return TRUE;
+ return true;
}
bool CThreadedSocket::Connect(const char * lpszHostAddress, UINT nHostPort)
{
- assert(lpszHostAddress != NULL);
+ ASSERT(lpszHostAddress != NULL);
SOCKADDR_IN sockAddr;
memset(&sockAddr,0,sizeof(sockAddr));
@@ -202,7 +199,7 @@ bool CThreadedSocket::Connect(const char * lpszHostAddress, UINT nHostPort) else
{
WSASetLastError(WSAEINVAL);
- return FALSE;
+ return false;
}
}
@@ -219,7 +216,7 @@ int CThreadedSocket::Receive(void* lpBuf, int nBufLen, int nFlags) return lg;
}
-int CThreadedSocket::ReceiveFrom(void* lpBuf, int nBufLen, String & rSocketAddress, UINT& rSocketPort, int nFlags)
+int CThreadedSocket::ReceiveFrom(void* lpBuf, int nBufLen, string & rSocketAddress, UINT& rSocketPort, int nFlags)
{
SOCKADDR_IN sockAddr;
@@ -306,7 +303,7 @@ void CThreadedSocket::AddMember( const char * lpszHostAddress ) }
void CThreadedSocket::AsyncSelect(long lEvent)
{
- assert(m_hSocket != INVALID_SOCKET);
+ ASSERT(m_hSocket != INVALID_SOCKET);
if ( WSAEventSelect(m_hSocket, m_hEvent[0], lEvent) )
throw( new CThreadedSocketException( "WSAEventSelect" ));
}
@@ -345,7 +342,7 @@ void CThreadedSocket::OnClose(int /*nErrorCode*/) void CThreadedSocket::Socket(int nSocketType, long lEvent, int nProtocolType, int nAddressFormat)
{
- assert(m_hSocket == INVALID_SOCKET);
+ ASSERT(m_hSocket == INVALID_SOCKET);
m_hSocket = socket(nAddressFormat,nSocketType,nProtocolType);
// m_hSocket = WSASocket ( nAddressFormat, nSocketType,nProtocolType, NULL, 0, 0 );
@@ -388,7 +385,7 @@ UINT CThreadedSocket::SocketThread( ) AsyncSelect(m_EventMask) ;
while ( m_hSocket != INVALID_SOCKET )
{
- err = WSAWaitForMultipleEvents( 2, m_hEvent, FALSE, WSA_INFINITE, TRUE);
+ err = WSAWaitForMultipleEvents( 2, m_hEvent, false, WSA_INFINITE, true);
switch ( err )
{
case WSA_WAIT_FAILED:
|