mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Use standard types and headers.
This commit is contained in:
parent
1e82d7b747
commit
a6ce7811ba
14
module/Vendor/SimpleSocket/ActiveSocket.cpp
vendored
14
module/Vendor/SimpleSocket/ActiveSocket.cpp
vendored
@ -51,7 +51,7 @@ CActiveSocket::CActiveSocket(CSocketType nType) : CSimpleSocket(nType)
|
||||
// ConnectTCP() -
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CActiveSocket::ConnectTCP(const char *pAddr, uint16 nPort)
|
||||
bool CActiveSocket::ConnectTCP(const char *pAddr, uint16_t nPort)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
struct in_addr stIpAddress;
|
||||
@ -78,7 +78,7 @@ bool CActiveSocket::ConnectTCP(const char *pAddr, uint16 nPort)
|
||||
memcpy(&stIpAddress, m_pHE->h_addr_list[0], m_pHE->h_length);
|
||||
m_stServerSockaddr.sin_addr.s_addr = stIpAddress.s_addr;
|
||||
|
||||
if ((int32)m_stServerSockaddr.sin_addr.s_addr == CSimpleSocket::SocketError)
|
||||
if ((int32_t)m_stServerSockaddr.sin_addr.s_addr == CSimpleSocket::SocketError)
|
||||
{
|
||||
TranslateSocketError();
|
||||
return bRetVal;
|
||||
@ -131,7 +131,7 @@ bool CActiveSocket::ConnectTCP(const char *pAddr, uint16 nPort)
|
||||
// ConnectUDP() -
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CActiveSocket::ConnectUDP(const char *pAddr, uint16 nPort)
|
||||
bool CActiveSocket::ConnectUDP(const char *pAddr, uint16_t nPort)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
struct in_addr stIpAddress;
|
||||
@ -158,7 +158,7 @@ bool CActiveSocket::ConnectUDP(const char *pAddr, uint16 nPort)
|
||||
memcpy(&stIpAddress, m_pHE->h_addr_list[0], m_pHE->h_length);
|
||||
m_stServerSockaddr.sin_addr.s_addr = stIpAddress.s_addr;
|
||||
|
||||
if ((int32)m_stServerSockaddr.sin_addr.s_addr == CSimpleSocket::SocketError)
|
||||
if ((int32_t)m_stServerSockaddr.sin_addr.s_addr == CSimpleSocket::SocketError)
|
||||
{
|
||||
TranslateSocketError();
|
||||
return bRetVal;
|
||||
@ -190,7 +190,7 @@ bool CActiveSocket::ConnectUDP(const char *pAddr, uint16 nPort)
|
||||
// ConnectRAW() -
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CActiveSocket::ConnectRAW(const char *pAddr, uint16 nPort)
|
||||
bool CActiveSocket::ConnectRAW(const char *pAddr, uint16_t nPort)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
struct in_addr stIpAddress;
|
||||
@ -216,7 +216,7 @@ bool CActiveSocket::ConnectRAW(const char *pAddr, uint16 nPort)
|
||||
memcpy(&stIpAddress, m_pHE->h_addr_list[0], m_pHE->h_length);
|
||||
m_stServerSockaddr.sin_addr.s_addr = stIpAddress.s_addr;
|
||||
|
||||
if ((int32)m_stServerSockaddr.sin_addr.s_addr == CSimpleSocket::SocketError)
|
||||
if ((int32_t)m_stServerSockaddr.sin_addr.s_addr == CSimpleSocket::SocketError)
|
||||
{
|
||||
TranslateSocketError();
|
||||
return bRetVal;
|
||||
@ -249,7 +249,7 @@ bool CActiveSocket::ConnectRAW(const char *pAddr, uint16 nPort)
|
||||
// Open() - Create a connection to a specified address on a specified port
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CActiveSocket::Open(const char *pAddr, uint16 nPort)
|
||||
bool CActiveSocket::Open(const char *pAddr, uint16_t nPort)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
|
||||
|
14
module/Vendor/SimpleSocket/PassiveSocket.cpp
vendored
14
module/Vendor/SimpleSocket/PassiveSocket.cpp
vendored
@ -48,7 +48,7 @@ CPassiveSocket::CPassiveSocket(CSocketType nType) : CSimpleSocket(nType)
|
||||
{
|
||||
}
|
||||
|
||||
bool CPassiveSocket::BindMulticast(const char *pInterface, const char *pGroup, uint16 nPort)
|
||||
bool CPassiveSocket::BindMulticast(const char *pInterface, const char *pGroup, uint16_t nPort)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
#ifdef _WIN32
|
||||
@ -127,7 +127,7 @@ bool CPassiveSocket::BindMulticast(const char *pInterface, const char *pGroup, u
|
||||
// Listen() -
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CPassiveSocket::Listen(const char *pAddr, uint16 nPort, int32 nConnectionBacklog)
|
||||
bool CPassiveSocket::Listen(const char *pAddr, uint16_t nPort, int32_t nConnectionBacklog)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
#ifdef _WIN32
|
||||
@ -135,7 +135,7 @@ bool CPassiveSocket::Listen(const char *pAddr, uint16 nPort, int32 nConnectionBa
|
||||
#else
|
||||
in_addr_t inAddr;
|
||||
|
||||
int32 nReuse;
|
||||
int32_t nReuse;
|
||||
nReuse = IPTOS_LOWDELAY;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -143,8 +143,8 @@ bool CPassiveSocket::Listen(const char *pAddr, uint16 nPort, int32 nConnectionBa
|
||||
// descriptor to be reused immediately after the socket is closed instead
|
||||
// of setting in a TIMED_WAIT state.
|
||||
//--------------------------------------------------------------------------
|
||||
SETSOCKOPT(m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&nReuse, sizeof(int32));
|
||||
SETSOCKOPT(m_socket, IPPROTO_TCP, IP_TOS, &nReuse, sizeof(int32));
|
||||
SETSOCKOPT(m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&nReuse, sizeof(int32_t));
|
||||
SETSOCKOPT(m_socket, IPPROTO_TCP, IP_TOS, &nReuse, sizeof(int32_t));
|
||||
#endif
|
||||
|
||||
memset(&m_stServerSockaddr,0,sizeof(m_stServerSockaddr));
|
||||
@ -214,7 +214,7 @@ bool CPassiveSocket::Listen(const char *pAddr, uint16 nPort, int32 nConnectionBa
|
||||
//------------------------------------------------------------------------------
|
||||
CActiveSocket *CPassiveSocket::Accept()
|
||||
{
|
||||
uint32 nSockLen;
|
||||
uint32_t nSockLen;
|
||||
CActiveSocket *pClientSocket = NULL;
|
||||
SOCKET socket = CSimpleSocket::SocketError;
|
||||
|
||||
@ -286,7 +286,7 @@ CActiveSocket *CPassiveSocket::Accept()
|
||||
// Send() - Send data on a valid socket
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CPassiveSocket::Send(const uint8 *pBuf, size_t bytesToSend)
|
||||
int32_t CPassiveSocket::Send(const uint8_t *pBuf, size_t bytesToSend)
|
||||
{
|
||||
SetSocketError(SocketSuccess);
|
||||
m_nBytesSent = 0;
|
||||
|
2
module/Vendor/SimpleSocket/README
vendored
2
module/Vendor/SimpleSocket/README
vendored
@ -80,7 +80,7 @@ int main(int argc, char **argv)
|
||||
//----------------------------------------------------------------------
|
||||
// Send a requtest the server requesting the current time.
|
||||
//----------------------------------------------------------------------
|
||||
if (socket.Send((const uint8 *)"\n", 1))
|
||||
if (socket.Send((const uint8_t *)"\n", 1))
|
||||
{
|
||||
//----------------------------------------------------------------------
|
||||
// Receive response from the server.
|
||||
|
98
module/Vendor/SimpleSocket/SimpleSocket.cpp
vendored
98
module/Vendor/SimpleSocket/SimpleSocket.cpp
vendored
@ -109,7 +109,7 @@ CSimpleSocket::CSimpleSocket(CSocketType nType) :
|
||||
|
||||
CSimpleSocket::CSimpleSocket(CSimpleSocket &socket)
|
||||
{
|
||||
m_pBuffer = new uint8[socket.m_nBufferSize];
|
||||
m_pBuffer = new uint8_t[socket.m_nBufferSize];
|
||||
m_nBufferSize = socket.m_nBufferSize;
|
||||
memcpy(m_pBuffer, socket.m_pBuffer, socket.m_nBufferSize);
|
||||
}
|
||||
@ -119,7 +119,7 @@ CSimpleSocket *CSimpleSocket::operator=(CSimpleSocket &socket)
|
||||
if (m_nBufferSize != socket.m_nBufferSize)
|
||||
{
|
||||
delete m_pBuffer;
|
||||
m_pBuffer = new uint8[socket.m_nBufferSize];
|
||||
m_pBuffer = new uint8_t[socket.m_nBufferSize];
|
||||
m_nBufferSize = socket.m_nBufferSize;
|
||||
memcpy(m_pBuffer, socket.m_pBuffer, socket.m_nBufferSize);
|
||||
}
|
||||
@ -194,7 +194,7 @@ bool CSimpleSocket::BindInterface(const char *pInterface)
|
||||
// SetMulticast()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetMulticast(bool bEnable, uint8 multicastTTL)
|
||||
bool CSimpleSocket::SetMulticast(bool bEnable, uint8_t multicastTTL)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
|
||||
@ -225,10 +225,10 @@ bool CSimpleSocket::SetMulticast(bool bEnable, uint8 multicastTTL)
|
||||
// SetSocketDscp()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetSocketDscp(int32 nDscp)
|
||||
bool CSimpleSocket::SetSocketDscp(int32_t nDscp)
|
||||
{
|
||||
bool bRetVal = true;
|
||||
int32 nTempVal = nDscp;
|
||||
int32_t nTempVal = nDscp;
|
||||
|
||||
nTempVal <<= 4;
|
||||
nTempVal /= 4;
|
||||
@ -251,9 +251,9 @@ bool CSimpleSocket::SetSocketDscp(int32 nDscp)
|
||||
// GetSocketDscp()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CSimpleSocket::GetSocketDscp(void)
|
||||
int32_t CSimpleSocket::GetSocketDscp(void)
|
||||
{
|
||||
int32 nTempVal = 0;
|
||||
int32_t nTempVal = 0;
|
||||
socklen_t nLen = 0;
|
||||
|
||||
if (IsSocketValid())
|
||||
@ -276,9 +276,9 @@ int32 CSimpleSocket::GetSocketDscp(void)
|
||||
// GetWindowSize()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
uint32 CSimpleSocket::GetWindowSize(uint32 nOptionName)
|
||||
uint32_t CSimpleSocket::GetWindowSize(uint32_t nOptionName)
|
||||
{
|
||||
uint32 nTcpWinSize = 0;
|
||||
uint32_t nTcpWinSize = 0;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// no socket given, return system default allocate our own new socket
|
||||
@ -307,7 +307,7 @@ uint32 CSimpleSocket::GetWindowSize(uint32 nOptionName)
|
||||
// SetWindowSize()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
uint32 CSimpleSocket::SetWindowSize(uint32 nOptionName, uint32 nWindowSize)
|
||||
uint32_t CSimpleSocket::SetWindowSize(uint32_t nOptionName, uint32_t nWindowSize)
|
||||
{
|
||||
//-------------------------------------------------------------------------
|
||||
// no socket given, return system default allocate our own new socket
|
||||
@ -334,12 +334,12 @@ uint32 CSimpleSocket::SetWindowSize(uint32 nOptionName, uint32 nWindowSize)
|
||||
bool CSimpleSocket::DisableNagleAlgoritm()
|
||||
{
|
||||
bool bRetVal = false;
|
||||
int32 nTcpNoDelay = 1;
|
||||
int32_t nTcpNoDelay = 1;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Set TCP NoDelay flag to true
|
||||
//----------------------------------------------------------------------
|
||||
if (SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nTcpNoDelay, sizeof(int32)) == 0)
|
||||
if (SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nTcpNoDelay, sizeof(int32_t)) == 0)
|
||||
{
|
||||
bRetVal = true;
|
||||
}
|
||||
@ -358,12 +358,12 @@ bool CSimpleSocket::DisableNagleAlgoritm()
|
||||
bool CSimpleSocket::EnableNagleAlgoritm()
|
||||
{
|
||||
bool bRetVal = false;
|
||||
int32 nTcpNoDelay = 0;
|
||||
int32_t nTcpNoDelay = 0;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Set TCP NoDelay flag to false
|
||||
//----------------------------------------------------------------------
|
||||
if (SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nTcpNoDelay, sizeof(int32)) == 0)
|
||||
if (SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nTcpNoDelay, sizeof(int32_t)) == 0)
|
||||
{
|
||||
bRetVal = true;
|
||||
}
|
||||
@ -379,7 +379,7 @@ bool CSimpleSocket::EnableNagleAlgoritm()
|
||||
// Send() - Send data on a valid socket
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CSimpleSocket::Send(const uint8 *pBuf, size_t bytesToSend)
|
||||
int32_t CSimpleSocket::Send(const uint8_t *pBuf, size_t bytesToSend)
|
||||
{
|
||||
SetSocketError(SocketSuccess);
|
||||
m_nBytesSent = 0;
|
||||
@ -513,20 +513,20 @@ bool CSimpleSocket::Shutdown(CShutdownMode nShutdown)
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::Flush()
|
||||
{
|
||||
int32 nTcpNoDelay = 1;
|
||||
int32 nCurFlags = 0;
|
||||
uint8 tmpbuf = 0;
|
||||
int32_t nTcpNoDelay = 1;
|
||||
int32_t nCurFlags = 0;
|
||||
uint8_t tmpbuf = 0;
|
||||
bool bRetVal = false;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Get the current setting of the TCP_NODELAY flag.
|
||||
//--------------------------------------------------------------------------
|
||||
if (GETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nCurFlags, sizeof(int32)) == 0)
|
||||
if (GETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nCurFlags, sizeof(int32_t)) == 0)
|
||||
{
|
||||
//----------------------------------------------------------------------
|
||||
// Set TCP NoDelay flag
|
||||
//----------------------------------------------------------------------
|
||||
if (SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nTcpNoDelay, sizeof(int32)) == 0)
|
||||
if (SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nTcpNoDelay, sizeof(int32_t)) == 0)
|
||||
{
|
||||
//------------------------------------------------------------------
|
||||
// Send empty byte stream to flush the TCP send buffer
|
||||
@ -542,7 +542,7 @@ bool CSimpleSocket::Flush()
|
||||
//----------------------------------------------------------------------
|
||||
// Reset the TCP_NODELAY flag to original state.
|
||||
//----------------------------------------------------------------------
|
||||
SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nCurFlags, sizeof(int32));
|
||||
SETSOCKOPT(m_socket, IPPROTO_TCP, TCP_NODELAY, &nCurFlags, sizeof(int32_t));
|
||||
}
|
||||
|
||||
return bRetVal;
|
||||
@ -554,19 +554,19 @@ bool CSimpleSocket::Flush()
|
||||
// Writev -
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CSimpleSocket::Writev(const struct iovec *pVector, size_t nCount)
|
||||
int32_t CSimpleSocket::Writev(const struct iovec *pVector, size_t nCount)
|
||||
{
|
||||
int32 nBytes = 0;
|
||||
int32 nBytesSent = 0;
|
||||
int32 i = 0;
|
||||
int32_t nBytes = 0;
|
||||
int32_t nBytesSent = 0;
|
||||
int32_t i = 0;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Send each buffer as a separate send, windows does not support this
|
||||
// function call.
|
||||
//--------------------------------------------------------------------------
|
||||
for (i = 0; i < (int32)nCount; i++)
|
||||
for (i = 0; i < (int32_t)nCount; i++)
|
||||
{
|
||||
if ((nBytes = Send((uint8 *)pVector[i].iov_base, pVector[i].iov_len)) == CSimpleSocket::SocketError)
|
||||
if ((nBytes = Send((uint8_t *)pVector[i].iov_base, pVector[i].iov_len)) == CSimpleSocket::SocketError)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -588,7 +588,7 @@ int32 CSimpleSocket::Writev(const struct iovec *pVector, size_t nCount)
|
||||
// Send() - Send data on a valid socket via a vector of buffers.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CSimpleSocket::Send(const struct iovec *sendVector, int32 nNumItems)
|
||||
int32_t CSimpleSocket::Send(const struct iovec *sendVector, int32_t nNumItems)
|
||||
{
|
||||
SetSocketError(SocketSuccess);
|
||||
m_nBytesSent = 0;
|
||||
@ -607,7 +607,7 @@ int32 CSimpleSocket::Send(const struct iovec *sendVector, int32 nNumItems)
|
||||
// SetReceiveTimeout()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetReceiveTimeout(int32 nRecvTimeoutSec, int32 nRecvTimeoutUsec)
|
||||
bool CSimpleSocket::SetReceiveTimeout(int32_t nRecvTimeoutSec, int32_t nRecvTimeoutUsec)
|
||||
{
|
||||
bool bRetVal = true;
|
||||
|
||||
@ -635,7 +635,7 @@ bool CSimpleSocket::SetReceiveTimeout(int32 nRecvTimeoutSec, int32 nRecvTimeoutU
|
||||
// SetSendTimeout()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetSendTimeout(int32 nSendTimeoutSec, int32 nSendTimeoutUsec)
|
||||
bool CSimpleSocket::SetSendTimeout(int32_t nSendTimeoutSec, int32_t nSendTimeoutUsec)
|
||||
{
|
||||
bool bRetVal = true;
|
||||
|
||||
@ -665,9 +665,9 @@ bool CSimpleSocket::SetSendTimeout(int32 nSendTimeoutSec, int32 nSendTimeoutUsec
|
||||
bool CSimpleSocket::SetOptionReuseAddr()
|
||||
{
|
||||
bool bRetVal = false;
|
||||
int32 nReuse = IPTOS_LOWDELAY;
|
||||
int32_t nReuse = IPTOS_LOWDELAY;
|
||||
|
||||
if (SETSOCKOPT(m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&nReuse, sizeof(int32)) == 0)
|
||||
if (SETSOCKOPT(m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&nReuse, sizeof(int32_t)) == 0)
|
||||
{
|
||||
bRetVal = true;
|
||||
}
|
||||
@ -683,7 +683,7 @@ bool CSimpleSocket::SetOptionReuseAddr()
|
||||
// SetOptionLinger()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetOptionLinger(bool bEnable, uint16 nTime)
|
||||
bool CSimpleSocket::SetOptionLinger(bool bEnable, uint16_t nTime)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
|
||||
@ -710,7 +710,7 @@ bool CSimpleSocket::SetOptionLinger(bool bEnable, uint16 nTime)
|
||||
// of scope.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CSimpleSocket::Receive(int32 nMaxBytes, uint8 * pBuffer )
|
||||
int32_t CSimpleSocket::Receive(int32_t nMaxBytes, uint8_t * pBuffer )
|
||||
{
|
||||
m_nBytesReceived = 0;
|
||||
|
||||
@ -722,7 +722,7 @@ int32 CSimpleSocket::Receive(int32 nMaxBytes, uint8 * pBuffer )
|
||||
return m_nBytesReceived;
|
||||
}
|
||||
|
||||
uint8 * pWorkBuffer = pBuffer;
|
||||
uint8_t * pWorkBuffer = pBuffer;
|
||||
if ( pBuffer == NULL )
|
||||
{
|
||||
//--------------------------------------------------------------------------
|
||||
@ -741,7 +741,7 @@ int32 CSimpleSocket::Receive(int32 nMaxBytes, uint8 * pBuffer )
|
||||
if (m_pBuffer == NULL)
|
||||
{
|
||||
m_nBufferSize = nMaxBytes;
|
||||
m_pBuffer = new uint8[nMaxBytes];
|
||||
m_pBuffer = new uint8_t[nMaxBytes];
|
||||
}
|
||||
|
||||
pWorkBuffer = m_pBuffer;
|
||||
@ -771,7 +771,7 @@ int32 CSimpleSocket::Receive(int32 nMaxBytes, uint8 * pBuffer )
|
||||
}
|
||||
case CSimpleSocket::SocketTypeUdp:
|
||||
{
|
||||
uint32 srcSize;
|
||||
uint32_t srcSize;
|
||||
|
||||
srcSize = sizeof(struct sockaddr_in);
|
||||
|
||||
@ -829,7 +829,7 @@ int32 CSimpleSocket::Receive(int32 nMaxBytes, uint8 * pBuffer )
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetNonblocking(void)
|
||||
{
|
||||
int32 nCurFlags;
|
||||
int32_t nCurFlags;
|
||||
|
||||
#if _WIN32
|
||||
nCurFlags = 1;
|
||||
@ -868,7 +868,7 @@ bool CSimpleSocket::SetNonblocking(void)
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::SetBlocking(void)
|
||||
{
|
||||
int32 nCurFlags;
|
||||
int32_t nCurFlags;
|
||||
|
||||
#if _WIN32
|
||||
nCurFlags = 0;
|
||||
@ -903,12 +903,12 @@ bool CSimpleSocket::SetBlocking(void)
|
||||
// SendFile() - stands-in for system provided sendfile
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
int32 CSimpleSocket::SendFile(int32 nOutFd, int32 nInFd, off_t *pOffset, int32 nCount)
|
||||
int32_t CSimpleSocket::SendFile(int32_t nOutFd, int32_t nInFd, off_t *pOffset, int32_t nCount)
|
||||
{
|
||||
int32 nOutCount = CSimpleSocket::SocketError;
|
||||
int32_t nOutCount = CSimpleSocket::SocketError;
|
||||
|
||||
static char szData[SOCKET_SENDFILE_BLOCKSIZE];
|
||||
int32 nInCount = 0;
|
||||
int32_t nInCount = 0;
|
||||
|
||||
if (lseek(nInFd, *pOffset, SEEK_SET) == -1)
|
||||
{
|
||||
@ -919,12 +919,12 @@ int32 CSimpleSocket::SendFile(int32 nOutFd, int32 nInFd, off_t *pOffset, int32 n
|
||||
{
|
||||
nInCount = (nCount - nOutCount) < SOCKET_SENDFILE_BLOCKSIZE ? (nCount - nOutCount) : SOCKET_SENDFILE_BLOCKSIZE;
|
||||
|
||||
if ((read(nInFd, szData, nInCount)) != (int32)nInCount)
|
||||
if ((read(nInFd, szData, nInCount)) != (int32_t)nInCount)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((SEND(nOutFd, szData, nInCount, 0)) != (int32)nInCount)
|
||||
if ((SEND(nOutFd, szData, nInCount, 0)) != (int32_t)nInCount)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ void CSimpleSocket::TranslateSocketError(void)
|
||||
}
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
int32 nError = WSAGetLastError();
|
||||
int32_t nError = WSAGetLastError();
|
||||
switch (nError)
|
||||
{
|
||||
case EXIT_SUCCESS:
|
||||
@ -1126,13 +1126,13 @@ const char *CSimpleSocket::DescribeError(CSocketError err)
|
||||
// Select()
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
bool CSimpleSocket::Select(int32 nTimeoutSec, int32 nTimeoutUSec)
|
||||
bool CSimpleSocket::Select(int32_t nTimeoutSec, int32_t nTimeoutUSec)
|
||||
{
|
||||
bool bRetVal = false;
|
||||
struct timeval *pTimeout = NULL;
|
||||
struct timeval timeout;
|
||||
int32 nNumDescriptors = -1;
|
||||
int32 nError = 0;
|
||||
int32_t nNumDescriptors = -1;
|
||||
int32_t nError = 0;
|
||||
|
||||
FD_ZERO(&m_errorFds);
|
||||
FD_ZERO(&m_readFds);
|
||||
@ -1169,7 +1169,7 @@ bool CSimpleSocket::Select(int32 nTimeoutSec, int32 nTimeoutUSec)
|
||||
//----------------------------------------------------------------------
|
||||
else if ((FD_ISSET(m_socket, &m_readFds)) || (FD_ISSET(m_socket, &m_writeFds)))
|
||||
{
|
||||
int32 nLen = sizeof(nError);
|
||||
int32_t nLen = sizeof(nError);
|
||||
|
||||
if (GETSOCKOPT(m_socket, SOL_SOCKET, SO_ERROR, &nError, &nLen) == 0)
|
||||
{
|
||||
|
@ -68,20 +68,20 @@ public:
|
||||
/// @param pAddr specifies the destination address to connect.
|
||||
/// @param nPort specifies the destination port.
|
||||
/// @return true if successful connection made, otherwise false.
|
||||
virtual bool Open(const char *pAddr, uint16 nPort);
|
||||
virtual bool Open(const char *pAddr, uint16_t nPort);
|
||||
|
||||
private:
|
||||
/// Utility function used to create a TCP connection, called from Open().
|
||||
/// @return true if successful connection made, otherwise false.
|
||||
bool ConnectTCP(const char *pAddr, uint16 nPort);
|
||||
bool ConnectTCP(const char *pAddr, uint16_t nPort);
|
||||
|
||||
/// Utility function used to create a UDP connection, called from Open().
|
||||
/// @return true if successful connection made, otherwise false.
|
||||
bool ConnectUDP(const char *pAddr, uint16 nPort);
|
||||
bool ConnectUDP(const char *pAddr, uint16_t nPort);
|
||||
|
||||
/// Utility function used to create a RAW connection, called from Open().
|
||||
/// @return true if successful connection made, otherwise false.
|
||||
bool ConnectRAW(const char *pAddr, uint16 nPort);
|
||||
bool ConnectRAW(const char *pAddr, uint16_t nPort);
|
||||
|
||||
private:
|
||||
struct hostent *m_pHE;
|
||||
|
64
module/Vendor/SimpleSocket/include/Host.h
vendored
64
module/Vendor/SimpleSocket/include/Host.h
vendored
@ -44,6 +44,9 @@
|
||||
#ifndef __HOST_H__
|
||||
#define __HOST_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -62,12 +65,6 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#if defined(_LINUX) || defined(_DARWIN)
|
||||
typedef unsigned char uint8;
|
||||
typedef char int8;
|
||||
typedef unsigned short uint16;
|
||||
typedef short int16;
|
||||
typedef unsigned int uint32;
|
||||
typedef int int32;
|
||||
typedef int SOCKET;
|
||||
#endif
|
||||
|
||||
@ -76,57 +73,12 @@ extern "C"
|
||||
void *iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef char int8;
|
||||
typedef unsigned short uint16;
|
||||
typedef short int16;
|
||||
typedef unsigned int uint32;
|
||||
typedef int int32;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned long long int uint64;
|
||||
typedef long long int int64;
|
||||
#elif (__WORDSIZE == 32)
|
||||
__extension__
|
||||
typedef long long int int64;
|
||||
__extension__
|
||||
typedef unsigned long long int uint64;
|
||||
#elif (__WORDSIZE == 64)
|
||||
typedef unsigned long int uint64;
|
||||
typedef long int int64;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifndef UINT8_MAX
|
||||
#define UINT8_MAX (UCHAR_MAX)
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX (USHRT_MAX)
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX (ULONG_MAX)
|
||||
#endif
|
||||
|
||||
#if __WORDSIZE == 64
|
||||
#define SIZE_MAX (18446744073709551615UL)
|
||||
#else
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX (4294967295U)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define ssize_t size_t
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
@ -140,8 +92,8 @@ extern "C"
|
||||
#define htonll(x) (x)
|
||||
#define ntohll(x) (x)
|
||||
#else
|
||||
#define htonll(x) ((((uint64)htonl(x)) << 32) + htonl(x >> 32))
|
||||
#define ntohll(x) ((((uint64)ntohl(x)) << 32) + ntohl(x >> 32))
|
||||
#define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32))
|
||||
#define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -161,7 +113,7 @@ extern "C"
|
||||
#define RECV(a,b,c,d) recv(a, (char *)b, c, d)
|
||||
#define RECVFROM(a,b,c,d,e,f) recvfrom(a, (char *)b, c, d, (sockaddr *)e, (int *)f)
|
||||
#define RECV_FLAGS MSG_WAITALL
|
||||
#define SELECT(a,b,c,d,e) select((int32)a,b,c,d,e)
|
||||
#define SELECT(a,b,c,d,e) select((int32_t)a,b,c,d,e)
|
||||
#define SEND(a,b,c,d) send(a, (const char *)b, (int)c, d)
|
||||
#define SENDTO(a,b,c,d,e,f) sendto(a, (const char *)b, (int)c, d, e, f)
|
||||
#define SEND_FLAGS 0
|
||||
@ -185,8 +137,8 @@ extern "C"
|
||||
#define RECVFROM(a,b,c,d,e,f) recvfrom(a, (char *)b, c, d, (sockaddr *)e, f)
|
||||
#define RECV_FLAGS MSG_WAITALL
|
||||
#define SELECT(a,b,c,d,e) select(a,b,c,d,e)
|
||||
#define SEND(a,b,c,d) send(a, (const int8 *)b, c, d)
|
||||
#define SENDTO(a,b,c,d,e,f) sendto(a, (const int8 *)b, c, d, e, f)
|
||||
#define SEND(a,b,c,d) send(a, (const int8_t *)b, c, d)
|
||||
#define SENDTO(a,b,c,d,e,f) sendto(a, (const int8_t *)b, c, d, e, f)
|
||||
#define SEND_FLAGS 0
|
||||
#define SENDFILE(a,b,c,d) sendfile(a, b, c, d)
|
||||
#define SET_SOCKET_ERROR(x,y) errno=y
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
/// condiitions will be set: CPassiveSocket::SocketAddressInUse, CPassiveSocket::SocketProtocolError,
|
||||
/// CPassiveSocket::SocketInvalidSocket. The following socket errors are for Linux/Unix
|
||||
/// derived systems only: CPassiveSocket::SocketInvalidSocketBuffer
|
||||
bool BindMulticast(const char *pInterface, const char *pGroup, uint16 nPort);
|
||||
bool BindMulticast(const char *pInterface, const char *pGroup, uint16_t nPort);
|
||||
|
||||
/// Create a listening socket at local ip address 'x.x.x.x' or 'localhost'
|
||||
/// if pAddr is NULL on port nPort.
|
||||
@ -95,7 +95,7 @@ public:
|
||||
/// conditions will be set: CPassiveSocket::SocketAddressInUse, CPassiveSocket::SocketProtocolError,
|
||||
/// CPassiveSocket::SocketInvalidSocket. The following socket errors are for Linux/Unix
|
||||
/// derived systems only: CPassiveSocket::SocketInvalidSocketBuffer
|
||||
virtual bool Listen(const char *pAddr, uint16 nPort, int32 nConnectionBacklog = 30000);
|
||||
virtual bool Listen(const char *pAddr, uint16_t nPort, int32_t nConnectionBacklog = 30000);
|
||||
|
||||
/// Attempts to send a block of data on an established connection.
|
||||
/// @param pBuf block of data to be sent.
|
||||
@ -109,7 +109,7 @@ public:
|
||||
/// CPassiveSocket::SocketProtocolError, CPassiveSocket::SocketNotconnected
|
||||
/// <br>\b Note: This function is used only for a socket of type
|
||||
/// CSimpleSocket::SocketTypeUdp
|
||||
virtual int32 Send(const uint8 *pBuf, size_t bytesToSend);
|
||||
virtual int32_t Send(const uint8_t *pBuf, size_t bytesToSend);
|
||||
|
||||
private:
|
||||
struct ip_mreq m_stMulticastRequest; /// group address for multicast
|
||||
|
@ -192,7 +192,7 @@ public:
|
||||
/// @param nTimeoutSec timeout in seconds for select.
|
||||
/// @param nTimeoutUSec timeout in micro seconds for select.
|
||||
/// @return true if socket has data ready, or false if not ready or timed out.
|
||||
virtual bool Select(int32 nTimeoutSec, int32 nTimeoutUSec);
|
||||
virtual bool Select(int32_t nTimeoutSec, int32_t nTimeoutUSec);
|
||||
|
||||
/// Does the current instance of the socket object contain a valid socket
|
||||
/// descriptor.
|
||||
@ -221,7 +221,7 @@ public:
|
||||
/// @return number of bytes actually received.
|
||||
/// @return of zero means the connection has been shutdown on the other side.
|
||||
/// @return of -1 means that an error has occurred.
|
||||
virtual int32 Receive(int32 nMaxBytes = 1, uint8 * pBuffer = 0);
|
||||
virtual int32_t Receive(int32_t nMaxBytes = 1, uint8_t * pBuffer = 0);
|
||||
|
||||
/// Attempts to send a block of data on an established connection.
|
||||
/// @param pBuf block of data to be sent.
|
||||
@ -229,7 +229,7 @@ public:
|
||||
/// @return number of bytes actually sent.
|
||||
/// @return of zero means the connection has been shutdown on the other side.
|
||||
/// @return of -1 means that an error has occurred.
|
||||
virtual int32 Send(const uint8 *pBuf, size_t bytesToSend);
|
||||
virtual int32_t Send(const uint8_t *pBuf, size_t bytesToSend);
|
||||
|
||||
/// Attempts to send at most nNumItem blocks described by sendVector
|
||||
/// to the socket descriptor associated with the socket object.
|
||||
@ -239,7 +239,7 @@ public:
|
||||
/// @return number of bytes actually sent, return of zero means the
|
||||
/// connection has been shutdown on the other side, and a return of -1
|
||||
/// means that an error has occurred.
|
||||
virtual int32 Send(const struct iovec *sendVector, int32 nNumItems);
|
||||
virtual int32_t Send(const struct iovec *sendVector, int32_t nNumItems);
|
||||
|
||||
/// Copies data between one file descriptor and another.
|
||||
/// On some systems this copying is done within the kernel, and thus is
|
||||
@ -253,7 +253,7 @@ public:
|
||||
/// @param pOffset from which to start reading data from input file.
|
||||
/// @param nCount number of bytes to copy between file descriptors.
|
||||
/// @return number of bytes written to the out socket descriptor.
|
||||
virtual int32 SendFile(int32 nOutFd, int32 nInFd, off_t *pOffset, int32 nCount);
|
||||
virtual int32_t SendFile(int32_t nOutFd, int32_t nInFd, off_t *pOffset, int32_t nCount);
|
||||
|
||||
/// Returns blocking/non-blocking state of socket.
|
||||
/// @return true if the socket is non-blocking, else return false.
|
||||
@ -273,21 +273,21 @@ public:
|
||||
/// pointer when finished. This memory is managed internally by the CSocket
|
||||
/// class.
|
||||
/// @return pointer to data if valid, else returns NULL.
|
||||
uint8 *GetData(void) {
|
||||
uint8_t *GetData(void) {
|
||||
return m_pBuffer;
|
||||
};
|
||||
|
||||
/// Returns the number of bytes received on the last call to
|
||||
/// CSocket::Receive().
|
||||
/// @return number of bytes received.
|
||||
int32 GetBytesReceived(void) {
|
||||
int32_t GetBytesReceived(void) {
|
||||
return m_nBytesReceived;
|
||||
};
|
||||
|
||||
/// Returns the number of bytes sent on the last call to
|
||||
/// CSocket::Send().
|
||||
/// @return number of bytes sent.
|
||||
int32 GetBytesSent(void) {
|
||||
int32_t GetBytesSent(void) {
|
||||
return m_nBytesSent;
|
||||
};
|
||||
|
||||
@ -306,7 +306,7 @@ public:
|
||||
/// @param bEnable true to enable option false to disable option.
|
||||
/// @param nTime time in seconds to linger.
|
||||
/// @return true if option successfully set
|
||||
bool SetOptionLinger(bool bEnable, uint16 nTime);
|
||||
bool SetOptionLinger(bool bEnable, uint16_t nTime);
|
||||
|
||||
/// Tells the kernel that even if this port is busy (in the TIME_WAIT state),
|
||||
/// go ahead and reuse it anyway. If it is busy, but with another state,
|
||||
@ -317,14 +317,14 @@ public:
|
||||
/// Gets the timeout value that specifies the maximum number of seconds a
|
||||
/// call to CSimpleSocket::Open waits until it completes.
|
||||
/// @return the length of time in seconds
|
||||
int32 GetConnectTimeoutSec(void) {
|
||||
int32_t GetConnectTimeoutSec(void) {
|
||||
return m_stConnectTimeout.tv_sec;
|
||||
};
|
||||
|
||||
/// Gets the timeout value that specifies the maximum number of microseconds
|
||||
/// a call to CSimpleSocket::Open waits until it completes.
|
||||
/// @return the length of time in microseconds
|
||||
int32 GetConnectTimeoutUSec(void) {
|
||||
int32_t GetConnectTimeoutUSec(void) {
|
||||
return m_stConnectTimeout.tv_usec;
|
||||
};
|
||||
|
||||
@ -338,7 +338,7 @@ public:
|
||||
/// @param nConnectTimeoutSec of timeout in seconds.
|
||||
/// @param nConnectTimeoutUsec of timeout in microseconds.
|
||||
/// @return true if socket connection timeout was successfully set.
|
||||
void SetConnectTimeout(int32 nConnectTimeoutSec, int32 nConnectTimeoutUsec = 0)
|
||||
void SetConnectTimeout(int32_t nConnectTimeoutSec, int32_t nConnectTimeoutUsec = 0)
|
||||
{
|
||||
m_stConnectTimeout.tv_sec = nConnectTimeoutSec;
|
||||
m_stConnectTimeout.tv_usec = nConnectTimeoutUsec;
|
||||
@ -347,14 +347,14 @@ public:
|
||||
/// Gets the timeout value that specifies the maximum number of seconds a
|
||||
/// a call to CSimpleSocket::Receive waits until it completes.
|
||||
/// @return the length of time in seconds
|
||||
int32 GetReceiveTimeoutSec(void) {
|
||||
int32_t GetReceiveTimeoutSec(void) {
|
||||
return m_stRecvTimeout.tv_sec;
|
||||
};
|
||||
|
||||
/// Gets the timeout value that specifies the maximum number of microseconds
|
||||
/// a call to CSimpleSocket::Receive waits until it completes.
|
||||
/// @return the length of time in microseconds
|
||||
int32 GetReceiveTimeoutUSec(void) {
|
||||
int32_t GetReceiveTimeoutUSec(void) {
|
||||
return m_stRecvTimeout.tv_usec;
|
||||
};
|
||||
|
||||
@ -368,14 +368,14 @@ public:
|
||||
/// @param nRecvTimeoutSec of timeout in seconds.
|
||||
/// @param nRecvTimeoutUsec of timeout in microseconds.
|
||||
/// @return true if socket timeout was successfully set.
|
||||
bool SetReceiveTimeout(int32 nRecvTimeoutSec, int32 nRecvTimeoutUsec = 0);
|
||||
bool SetReceiveTimeout(int32_t nRecvTimeoutSec, int32_t nRecvTimeoutUsec = 0);
|
||||
|
||||
/// Enable/disable multicast for a socket. This options is only valid for
|
||||
/// socket descriptors of type CSimpleSocket::SocketTypeUdp.
|
||||
/// @return true if multicast was enabled or false if socket type is not
|
||||
/// CSimpleSocket::SocketTypeUdp and the error will be set to
|
||||
/// CSimpleSocket::SocketProtocolError
|
||||
bool SetMulticast(bool bEnable, uint8 multicastTTL = 1);
|
||||
bool SetMulticast(bool bEnable, uint8_t multicastTTL = 1);
|
||||
|
||||
/// Return true if socket is multicast or false is socket is unicast
|
||||
/// @return true if multicast is enabled
|
||||
@ -390,21 +390,21 @@ public:
|
||||
/// Gets the timeout value that specifies the maximum number of seconds a
|
||||
/// a call to CSimpleSocket::Send waits until it completes.
|
||||
/// @return the length of time in seconds
|
||||
int32 GetSendTimeoutSec(void) {
|
||||
int32_t GetSendTimeoutSec(void) {
|
||||
return m_stSendTimeout.tv_sec;
|
||||
};
|
||||
|
||||
/// Gets the timeout value that specifies the maximum number of microseconds
|
||||
/// a call to CSimpleSocket::Send waits until it completes.
|
||||
/// @return the length of time in microseconds
|
||||
int32 GetSendTimeoutUSec(void) {
|
||||
int32_t GetSendTimeoutUSec(void) {
|
||||
return m_stSendTimeout.tv_usec;
|
||||
};
|
||||
|
||||
/// Gets the timeout value that specifies the maximum amount of time a call
|
||||
/// to CSimpleSocket::Send waits until it completes.
|
||||
/// @return the length of time in seconds
|
||||
bool SetSendTimeout(int32 nSendTimeoutSec, int32 nSendTimeoutUsec = 0);
|
||||
bool SetSendTimeout(int32_t nSendTimeoutSec, int32_t nSendTimeoutUsec = 0);
|
||||
|
||||
/// Returns the last error that occured for the instace of the CSimpleSocket
|
||||
/// instance. This method should be called immediately to retrieve the
|
||||
@ -416,13 +416,13 @@ public:
|
||||
|
||||
/// Get the total time the of the last operation in milliseconds.
|
||||
/// @return number of milliseconds of last operation.
|
||||
uint32 GetTotalTimeMs() {
|
||||
uint32_t GetTotalTimeMs() {
|
||||
return m_timer.GetMilliSeconds();
|
||||
};
|
||||
|
||||
/// Get the total time the of the last operation in microseconds.
|
||||
/// @return number of microseconds or last operation.
|
||||
uint32 GetTotalTimeUsec() {
|
||||
uint32_t GetTotalTimeUsec() {
|
||||
return m_timer.GetMicroSeconds();
|
||||
};
|
||||
|
||||
@ -457,7 +457,7 @@ public:
|
||||
|
||||
/// Returns the port number on which the client is connected.
|
||||
/// @return client port number.
|
||||
uint16 GetClientPort() {
|
||||
uint16_t GetClientPort() {
|
||||
return m_stClientSockaddr.sin_port;
|
||||
};
|
||||
|
||||
@ -469,35 +469,35 @@ public:
|
||||
|
||||
/// Returns the port number on which the server is connected.
|
||||
/// @return server port number.
|
||||
uint16 GetServerPort() {
|
||||
uint16_t GetServerPort() {
|
||||
return ntohs(m_stServerSockaddr.sin_port);
|
||||
};
|
||||
|
||||
/// Get the TCP receive buffer window size for the current socket object.
|
||||
/// <br><br>\b NOTE: Linux will set the receive buffer to twice the value passed.
|
||||
/// @return zero on failure else the number of bytes of the TCP receive buffer window size if successful.
|
||||
uint32 GetReceiveWindowSize() {
|
||||
uint32_t GetReceiveWindowSize() {
|
||||
return GetWindowSize(SO_RCVBUF);
|
||||
};
|
||||
|
||||
/// Get the TCP send buffer window size for the current socket object.
|
||||
/// <br><br>\b NOTE: Linux will set the send buffer to twice the value passed.
|
||||
/// @return zero on failure else the number of bytes of the TCP receive buffer window size if successful.
|
||||
uint32 GetSendWindowSize() {
|
||||
uint32_t GetSendWindowSize() {
|
||||
return GetWindowSize(SO_SNDBUF);
|
||||
};
|
||||
|
||||
/// Set the TCP receive buffer window size for the current socket object.
|
||||
/// <br><br>\b NOTE: Linux will set the receive buffer to twice the value passed.
|
||||
/// @return zero on failure else the number of bytes of the TCP send buffer window size if successful.
|
||||
uint32 SetReceiveWindowSize(uint32 nWindowSize) {
|
||||
uint32_t SetReceiveWindowSize(uint32_t nWindowSize) {
|
||||
return SetWindowSize(SO_RCVBUF, nWindowSize);
|
||||
};
|
||||
|
||||
/// Set the TCP send buffer window size for the current socket object.
|
||||
/// <br><br>\b NOTE: Linux will set the send buffer to twice the value passed.
|
||||
/// @return zero on failure else the number of bytes of the TCP send buffer window size if successful.
|
||||
uint32 SetSendWindowSize(uint32 nWindowSize) {
|
||||
uint32_t SetSendWindowSize(uint32_t nWindowSize) {
|
||||
return SetWindowSize(SO_SNDBUF, nWindowSize);
|
||||
};
|
||||
|
||||
@ -526,11 +526,11 @@ protected:
|
||||
private:
|
||||
/// Generic function used to get the send/receive window size
|
||||
/// @return zero on failure else the number of bytes of the TCP window size if successful.
|
||||
uint32 GetWindowSize(uint32 nOptionName);
|
||||
uint32_t GetWindowSize(uint32_t nOptionName);
|
||||
|
||||
/// Generic function used to set the send/receive window size
|
||||
/// @return zero on failure else the number of bytes of the TCP window size if successful.
|
||||
uint32 SetWindowSize(uint32 nOptionName, uint32 nWindowSize);
|
||||
uint32_t SetWindowSize(uint32_t nOptionName, uint32_t nWindowSize);
|
||||
|
||||
|
||||
/// Attempts to send at most nNumItem blocks described by sendVector
|
||||
@ -542,7 +542,7 @@ private:
|
||||
/// @return number of bytes actually sent, return of zero means the
|
||||
/// connection has been shutdown on the other side, and a return of -1
|
||||
/// means that an error has occurred.
|
||||
int32 Writev(const struct iovec *pVector, size_t nCount);
|
||||
int32_t Writev(const struct iovec *pVector, size_t nCount);
|
||||
|
||||
/// Flush the socket descriptor owned by the object.
|
||||
/// @return true data was successfully sent, else return false;
|
||||
@ -553,13 +553,13 @@ private:
|
||||
protected:
|
||||
SOCKET m_socket; /// socket handle
|
||||
CSocketError m_socketErrno; /// number of last error
|
||||
uint8 *m_pBuffer; /// internal send/receive buffer
|
||||
int32 m_nBufferSize; /// size of internal send/receive buffer
|
||||
int32 m_nSocketDomain; /// socket type PF_INET, PF_INET6
|
||||
uint8_t *m_pBuffer; /// internal send/receive buffer
|
||||
int32_t m_nBufferSize; /// size of internal send/receive buffer
|
||||
int32_t m_nSocketDomain; /// socket type PF_INET, PF_INET6
|
||||
CSocketType m_nSocketType; /// socket type - UDP, TCP or RAW
|
||||
int32 m_nBytesReceived; /// number of bytes received
|
||||
int32 m_nBytesSent; /// number of bytes sent
|
||||
uint32 m_nFlags; /// socket flags
|
||||
int32_t m_nBytesReceived; /// number of bytes received
|
||||
int32_t m_nBytesSent; /// number of bytes sent
|
||||
uint32_t m_nFlags; /// socket flags
|
||||
bool m_bIsBlocking; /// is socket blocking
|
||||
bool m_bIsMulticast; /// is the UDP socket multicast;
|
||||
struct timeval m_stConnectTimeout; /// connection timeout
|
||||
|
10
module/Vendor/SimpleSocket/include/StatTimer.h
vendored
10
module/Vendor/SimpleSocket/include/StatTimer.h
vendored
@ -90,11 +90,11 @@ public:
|
||||
struct timeval GetEndTime() { return m_endTime; };
|
||||
void SetEndTime() { GET_CLOCK_COUNT(&m_endTime); };
|
||||
|
||||
uint32 GetMilliSeconds() { return (CalcTotalUSec() / MILLISECONDS_CONVERSION); };
|
||||
uint32 GetMicroSeconds() { return (CalcTotalUSec()); };
|
||||
uint32 GetSeconds() { return (CalcTotalUSec() / MICROSECONDS_CONVERSION); };
|
||||
uint32_t GetMilliSeconds() { return (CalcTotalUSec() / MILLISECONDS_CONVERSION); };
|
||||
uint32_t GetMicroSeconds() { return (CalcTotalUSec()); };
|
||||
uint32_t GetSeconds() { return (CalcTotalUSec() / MICROSECONDS_CONVERSION); };
|
||||
|
||||
uint32 GetCurrentTime()
|
||||
uint32_t GetCurrentTime()
|
||||
{
|
||||
struct timeval tmpTime;
|
||||
GET_CLOCK_COUNT(&tmpTime);
|
||||
@ -102,7 +102,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
uint32 CalcTotalUSec() { return (((m_endTime.tv_sec - m_startTime.tv_sec) * MICROSECONDS_CONVERSION) +
|
||||
uint32_t CalcTotalUSec() { return (((m_endTime.tv_sec - m_startTime.tv_sec) * MICROSECONDS_CONVERSION) +
|
||||
(m_endTime.tv_usec - m_startTime.tv_usec)); };
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user