- socketpro.zip
- netdemo
- bin
- DNSResolver.exe
- GetHtml.exe
- IONet.exe
- MultipleSvs.exe
- MultiSvs.exe
- MultiSvsClient.exe
- NetBaseR.dll
- SafeSocket.exe
- SecureSocket.exe
- SpeedTest.exe
- ClientComponents
- ClientSocket.dll
- DResolver.dll
- SBroker.dll
- SockFile.dll
- help
- include
- lib
- NetBaseR.lib
- MultiSvsSample
- Samples
- client
- DnsSvs
- GetHTML
- InternetIO
- MultiSvsSample
- SecureSocket
- SpeedTest
- DResolver
- Svr
- SvrComponents
- MultipleSvs.exe
- MultiSvs.exe
- NetBaseR.dll
- SafeSocket.exe
- trash
|
// This is a part of the SocketPro package.
// Copyright (C) 2000-2002 UDAParts
// All rights reserved.
//
// This source code is only intended as a supplement to the
// SocketPro Classes Reference and related
// electronic documentation provided with the package.
// See these sources for detailed information regarding this
// UDAParts product.
// Please don't disclose any source code of the software to any person or entity,
//
// Please don't decompile, disassemble, or reverse engineer any object code of
// any portion of the software.
//
// Copyright (c) 2002 by Yuancai (Charlie) Ye
// yekerui@yahoo.com
#ifndef ___SOCKPRO__UTIL_HEADER_FILE___H___
#define ___SOCKPRO__UTIL_HEADER_FILE___H___
class CAutoLock
{
public:
CAutoLock(CRITICAL_SECTION *pCriticalSection)
{
m_pCriticalSection=pCriticalSection;
if(m_pCriticalSection)
{
::EnterCriticalSection(m_pCriticalSection);
}
}
virtual ~CAutoLock()
{
if(m_pCriticalSection)
::LeaveCriticalSection(m_pCriticalSection);
}
private:
CRITICAL_SECTION *m_pCriticalSection;
};
class CPacking
{
public:
CPacking()
{
m_nLen=0;
m_pBuffer=NULL;
}
virtual ~CPacking()
{
if(m_pBuffer)
{
free(m_pBuffer);
}
}
void Empty()
{
if(m_pBuffer)
{
free(m_pBuffer);
m_pBuffer=NULL;
}
m_nLen=0;
}
void Pack(const void* pData, unsigned long nBufferLen)
{
m_pBuffer = realloc(m_pBuffer, m_nLen+nBufferLen);
memcpy((BYTE*)m_pBuffer+m_nLen, pData, nBufferLen);
m_nLen += nBufferLen;
}
void Insert(unsigned long nPos, const void* pData, unsigned long nBufferLen)
{
if(!pData || nBufferLen==0)
return;
if(nPos>m_nLen)
nPos=m_nLen;
void *pBuffer=malloc(nBufferLen+m_nLen);
if(nPos)
memcpy(pBuffer, m_pBuffer, nPos);
memcpy((BYTE*)pBuffer + nPos, pData, nBufferLen);
memcpy((BYTE*)pBuffer + nPos + nBufferLen, (BYTE*)m_pBuffer + nPos, m_nLen-nPos);
free(m_pBuffer);
m_pBuffer = pBuffer;
m_nLen += nBufferLen;
}
public:
unsigned long m_nLen;
void *m_pBuffer;
};
#endif
// This is a part of the SocketPro package.
// Copyright (C) 2000-2002 UDAParts
// All rights reserved.
//
// This source code is only intended as a supplement to the
// SocketPro Classes Reference and related
// electronic documentation provided with the package.
// See these sources for detailed information regarding this
// UDAParts product.
// Please don't disclose any source code of the software to any person or entity,
//
// Please don't decompile, disassemble, or reverse engineer any object code of
// any portion of the software.
//
// Copyright (c) 2002 by Yuancai (Charlie) Ye
// yekerui@yahoo.com
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Yuancai (Charlie) Ye, an experienced C/C++ software engineer, lives in Atlanta, Georgia. He is an expert at continuous inline request/result batching, real-time stream processing, asynchronous data transferring and parallel computation for the best communication throughput and latency. He has been working at SocketPro (https://github.com/udaparts/socketpro) for more than fifteen years.