improved variable type consistency -> changed unsigned char in uint8_t (removed TODO comments and copy operations)
This commit is contained in:
parent
25a34ae8c0
commit
ffe0869129
10 changed files with 59 additions and 83 deletions
|
@ -54,12 +54,12 @@ int CAudioCompression::Init ( const int iNewAudioLen,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<unsigned char> CAudioCompression::Encode ( const CVector<short>& vecsAudio )
|
CVector<uint8_t> CAudioCompression::Encode ( const CVector<short>& vecsAudio )
|
||||||
{
|
{
|
||||||
if ( eAudComprType == CT_NONE )
|
if ( eAudComprType == CT_NONE )
|
||||||
{
|
{
|
||||||
// no compression, simply ship pure samples
|
// no compression, simply ship pure samples
|
||||||
CVector<unsigned char> vecbyOut ( iCodeSize );
|
CVector<uint8_t> vecbyOut ( iCodeSize );
|
||||||
const int iAudSize = iCodeSize / 2;
|
const int iAudSize = iCodeSize / 2;
|
||||||
|
|
||||||
for ( int i = 0; i < iAudSize; i++ )
|
for ( int i = 0; i < iAudSize; i++ )
|
||||||
|
@ -80,12 +80,12 @@ CVector<unsigned char> CAudioCompression::Encode ( const CVector<short>& vecsAud
|
||||||
return MsAdpcm.Encode ( vecsAudio ); // MS-ADPCM
|
return MsAdpcm.Encode ( vecsAudio ); // MS-ADPCM
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return CVector<unsigned char> ( 0 );
|
return CVector<uint8_t> ( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<short> CAudioCompression::Decode ( const CVector<unsigned char>& vecbyAdpcm )
|
CVector<short> CAudioCompression::Decode ( const CVector<uint8_t>& vecbyAdpcm )
|
||||||
{
|
{
|
||||||
if ( eAudComprType == CT_NONE )
|
if ( eAudComprType == CT_NONE )
|
||||||
{
|
{
|
||||||
|
@ -138,11 +138,11 @@ int CImaAdpcm::Init ( const int iNewAudioLen )
|
||||||
return iAdpcmSize;
|
return iAdpcmSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<unsigned char> CImaAdpcm::Encode ( const CVector<short>& vecsAudio )
|
CVector<uint8_t> CImaAdpcm::Encode ( const CVector<short>& vecsAudio )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CVector<unsigned char> vecbyAdpcm;
|
CVector<uint8_t> vecbyAdpcm;
|
||||||
CVector<unsigned char> vecbyAdpcmTemp;
|
CVector<uint8_t> vecbyAdpcmTemp;
|
||||||
|
|
||||||
// init size
|
// init size
|
||||||
vecbyAdpcm.Init ( iAdpcmSize );
|
vecbyAdpcm.Init ( iAdpcmSize );
|
||||||
|
@ -222,7 +222,7 @@ CVector<unsigned char> CImaAdpcm::Encode ( const CVector<short>& vecsAudio )
|
||||||
return vecbyAdpcm;
|
return vecbyAdpcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<short> CImaAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
|
CVector<short> CImaAdpcm::Decode ( const CVector<uint8_t>& vecbyAdpcm )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CVector<short> vecsAudio;
|
CVector<short> vecsAudio;
|
||||||
|
@ -325,10 +325,10 @@ int CMsAdpcm::Init ( const int iNewAudioLen )
|
||||||
return iAdpcmSize;
|
return iAdpcmSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<unsigned char> CMsAdpcm::Encode ( const CVector<short>& vecsAudio )
|
CVector<uint8_t> CMsAdpcm::Encode ( const CVector<short>& vecsAudio )
|
||||||
{
|
{
|
||||||
CVector<short> vecsAudioTemp;
|
CVector<short> vecsAudioTemp;
|
||||||
CVector<unsigned char> vecbyAdpcm;
|
CVector<uint8_t> vecbyAdpcm;
|
||||||
|
|
||||||
// init size
|
// init size
|
||||||
vecsAudioTemp.Init ( iAudSize );
|
vecsAudioTemp.Init ( iAudSize );
|
||||||
|
@ -354,8 +354,8 @@ CVector<unsigned char> CMsAdpcm::Encode ( const CVector<short>& vecsAudio )
|
||||||
|
|
||||||
|
|
||||||
/* Encode the samples as 4 bit ------------------------------------------ */
|
/* Encode the samples as 4 bit ------------------------------------------ */
|
||||||
unsigned int blockindx = 7;
|
unsigned int blockindx = 7;
|
||||||
unsigned char byte = 0;
|
uint8_t byte = 0;
|
||||||
|
|
||||||
for ( int k = 2; k < iAudSize; k++ )
|
for ( int k = 2; k < iAudSize; k++ )
|
||||||
{
|
{
|
||||||
|
@ -413,7 +413,7 @@ CVector<unsigned char> CMsAdpcm::Encode ( const CVector<short>& vecsAudio )
|
||||||
return vecbyAdpcm;
|
return vecbyAdpcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<short> CMsAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
|
CVector<short> CMsAdpcm::Decode ( const CVector<uint8_t>& vecbyAdpcm )
|
||||||
{
|
{
|
||||||
CVector<short> vecsAudio;
|
CVector<short> vecsAudio;
|
||||||
short bytecode;
|
short bytecode;
|
||||||
|
|
|
@ -82,9 +82,9 @@ public:
|
||||||
CImaAdpcm() : iStepindEnc ( 0 ) {}
|
CImaAdpcm() : iStepindEnc ( 0 ) {}
|
||||||
virtual ~CImaAdpcm() {}
|
virtual ~CImaAdpcm() {}
|
||||||
|
|
||||||
int Init ( const int iNewAudioLen );
|
int Init ( const int iNewAudioLen );
|
||||||
CVector<unsigned char> Encode ( const CVector<short>& vecsAudio );
|
CVector<uint8_t> Encode ( const CVector<short>& vecsAudio );
|
||||||
CVector<short> Decode ( const CVector<unsigned char>& vecbyAdpcm );
|
CVector<short> Decode ( const CVector<uint8_t>& vecbyAdpcm );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int iAudSize;
|
int iAudSize;
|
||||||
|
@ -116,9 +116,9 @@ public:
|
||||||
CMsAdpcm() {}
|
CMsAdpcm() {}
|
||||||
virtual ~CMsAdpcm() {}
|
virtual ~CMsAdpcm() {}
|
||||||
|
|
||||||
int Init ( const int iNewAudioLen );
|
int Init ( const int iNewAudioLen );
|
||||||
CVector<unsigned char> Encode ( const CVector<short>& vecsAudio );
|
CVector<uint8_t> Encode ( const CVector<short>& vecsAudio );
|
||||||
CVector<short> Decode ( const CVector<unsigned char>& vecbyAdpcm );
|
CVector<short> Decode ( const CVector<uint8_t>& vecbyAdpcm );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int iAudSize;
|
int iAudSize;
|
||||||
|
@ -137,10 +137,10 @@ public:
|
||||||
CAudioCompression() {}
|
CAudioCompression() {}
|
||||||
virtual ~CAudioCompression() {}
|
virtual ~CAudioCompression() {}
|
||||||
|
|
||||||
int Init ( const int iNewAudioLen,
|
int Init ( const int iNewAudioLen,
|
||||||
const EAudComprType eNewAuCoTy );
|
const EAudComprType eNewAuCoTy );
|
||||||
CVector<unsigned char> Encode ( const CVector<short>& vecsAudio );
|
CVector<uint8_t> Encode ( const CVector<short>& vecsAudio );
|
||||||
CVector<short> Decode ( const CVector<unsigned char>& vecbyAdpcm );
|
CVector<short> Decode ( const CVector<uint8_t>& vecbyAdpcm );
|
||||||
|
|
||||||
EAudComprType GetType() { return eAudComprType; }
|
EAudComprType GetType() { return eAudComprType; }
|
||||||
|
|
||||||
|
|
|
@ -363,9 +363,9 @@ int CChannelSet::CheckAddr ( const CHostAddress& Addr )
|
||||||
return INVALID_CHANNEL_ID;
|
return INVALID_CHANNEL_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
|
bool CChannelSet::PutData ( const CVector<uint8_t>& vecbyRecBuf,
|
||||||
const int iNumBytesRead,
|
const int iNumBytesRead,
|
||||||
const CHostAddress& HostAdr )
|
const CHostAddress& HostAdr )
|
||||||
{
|
{
|
||||||
bool bAudioOK = false;
|
bool bAudioOK = false;
|
||||||
bool bNewChannelReserved = false;
|
bool bNewChannelReserved = false;
|
||||||
|
@ -1029,7 +1029,7 @@ void CChannel::CreateNetTranspPropsMessFromCurrentSettings()
|
||||||
Protocol.CreateNetwTranspPropsMes ( NetworkTransportProps );
|
Protocol.CreateNetwTranspPropsMes ( NetworkTransportProps );
|
||||||
}
|
}
|
||||||
|
|
||||||
EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
||||||
int iNumBytes )
|
int iNumBytes )
|
||||||
{
|
{
|
||||||
EPutDataStat eRet = PS_GEN_ERROR;
|
EPutDataStat eRet = PS_GEN_ERROR;
|
||||||
|
@ -1235,13 +1235,13 @@ EGetDataStat CChannel::GetData ( CVector<double>& vecdData )
|
||||||
return eGetStatus;
|
return eGetStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
|
CVector<uint8_t> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
|
||||||
{
|
{
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
// if the block is not ready we have to initialize with zero length to
|
// if the block is not ready we have to initialize with zero length to
|
||||||
// tell the following network send routine that nothing should be sent
|
// tell the following network send routine that nothing should be sent
|
||||||
CVector<unsigned char> vecbySendBuf ( 0 );
|
CVector<uint8_t> vecbySendBuf ( 0 );
|
||||||
|
|
||||||
if ( bIsServer )
|
if ( bIsServer )
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,11 +80,11 @@ public:
|
||||||
CChannel ( const bool bNIsServer = true );
|
CChannel ( const bool bNIsServer = true );
|
||||||
virtual ~CChannel() {}
|
virtual ~CChannel() {}
|
||||||
|
|
||||||
EPutDataStat PutData ( const CVector<unsigned char>& vecbyData,
|
EPutDataStat PutData ( const CVector<uint8_t>& vecbyData,
|
||||||
int iNumBytes );
|
int iNumBytes );
|
||||||
EGetDataStat GetData ( CVector<double>& vecdData );
|
EGetDataStat GetData ( CVector<double>& vecdData );
|
||||||
|
|
||||||
CVector<unsigned char> PrepSendPacket ( const CVector<short>& vecsNPacket );
|
CVector<uint8_t> PrepSendPacket ( const CVector<short>& vecsNPacket );
|
||||||
|
|
||||||
bool IsConnected() const { return iConTimeOut > 0; }
|
bool IsConnected() const { return iConTimeOut > 0; }
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ public:
|
||||||
CChannelSet ( const int iNewUploadRateLimitKbps = DEF_MAX_UPLOAD_RATE_KBPS );
|
CChannelSet ( const int iNewUploadRateLimitKbps = DEF_MAX_UPLOAD_RATE_KBPS );
|
||||||
virtual ~CChannelSet() {}
|
virtual ~CChannelSet() {}
|
||||||
|
|
||||||
bool PutData ( const CVector<unsigned char>& vecbyRecBuf,
|
bool PutData ( const CVector<uint8_t>& vecbyRecBuf,
|
||||||
const int iNumBytesRead, const CHostAddress& HostAdr );
|
const int iNumBytesRead, const CHostAddress& HostAdr );
|
||||||
|
|
||||||
int GetFreeChan();
|
int GetFreeChan();
|
||||||
|
@ -256,8 +256,8 @@ public:
|
||||||
bool IsConnected ( const int iChanNum )
|
bool IsConnected ( const int iChanNum )
|
||||||
{ return vecChannels[iChanNum].IsConnected(); }
|
{ return vecChannels[iChanNum].IsConnected(); }
|
||||||
|
|
||||||
CVector<unsigned char> PrepSendPacket ( const int iChanNum,
|
CVector<uint8_t> PrepSendPacket ( const int iChanNum,
|
||||||
const CVector<short>& vecsNPacket )
|
const CVector<short>& vecsNPacket )
|
||||||
{ return vecChannels[iChanNum].PrepSendPacket ( vecsNPacket ); }
|
{ return vecChannels[iChanNum].PrepSendPacket ( vecsNPacket ); }
|
||||||
|
|
||||||
CHostAddress GetAddress ( const int iChanNum )
|
CHostAddress GetAddress ( const int iChanNum )
|
||||||
|
|
|
@ -66,17 +66,9 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
||||||
|
|
||||||
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
||||||
{
|
{
|
||||||
|
|
||||||
// convert unsigned uint8_t in char, TODO convert all buffers in uint8_t
|
|
||||||
CVector<unsigned char> vecbyDataConv ( vecMessage.Size() );
|
|
||||||
for ( int i = 0; i < vecMessage.Size(); i++ ) {
|
|
||||||
vecbyDataConv[i] = static_cast<unsigned char> ( vecMessage[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// the protocol queries me to call the function to send the message
|
// the protocol queries me to call the function to send the message
|
||||||
// send it through the network
|
// send it through the network
|
||||||
Socket.SendPacket ( vecbyDataConv, Channel.GetAddress() );
|
Socket.SendPacket ( vecMessage, Channel.GetAddress() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::OnReqJittBufSize()
|
void CClient::OnReqJittBufSize()
|
||||||
|
|
|
@ -271,7 +271,7 @@ void CProtocol::CreateAndSendAcknMess ( const int& iID, const int& iCnt )
|
||||||
emit MessReadyForSending ( vecAcknMessage );
|
emit MessReadyForSending ( vecAcknMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
|
bool CProtocol::ParseMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
const int iNumBytes )
|
const int iNumBytes )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -282,16 +282,7 @@ bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||||
int iRecCounter, iRecID;
|
int iRecCounter, iRecID;
|
||||||
CVector<uint8_t> vecData;
|
CVector<uint8_t> vecData;
|
||||||
|
|
||||||
|
if ( !ParseMessageFrame ( vecbyData, iNumBytes, iRecCounter, iRecID, vecData ) )
|
||||||
// convert unsigned char in uint8_t, TODO convert all buffers in uint8_t
|
|
||||||
CVector<uint8_t> vecbyDataConv ( iNumBytes );
|
|
||||||
for ( int i = 0; i < iNumBytes; i++ ) {
|
|
||||||
vecbyDataConv[i] = static_cast<uint8_t> ( vecbyData[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// important: vecbyDataConv must have iNumBytes to get it work!!!
|
|
||||||
if ( !ParseMessageFrame ( vecbyDataConv, iRecCounter, iRecID, vecData ) )
|
|
||||||
{
|
{
|
||||||
// In case we received a message and returned an answer but our answer
|
// In case we received a message and returned an answer but our answer
|
||||||
// did not make it to the receiver, he will resend his message. We check
|
// did not make it to the receiver, he will resend his message. We check
|
||||||
|
@ -926,6 +917,7 @@ bool CProtocol::EvaluateReqNetwTranspPropsMes ( const CVector<uint8_t>& vecData
|
||||||
* Message generation (parsing) *
|
* Message generation (parsing) *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
||||||
|
const int iNumBytesIn,
|
||||||
int& iCnt,
|
int& iCnt,
|
||||||
int& iID,
|
int& iID,
|
||||||
CVector<uint8_t>& vecData )
|
CVector<uint8_t>& vecData )
|
||||||
|
@ -936,11 +928,8 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
||||||
int iLenBy, i;
|
int iLenBy, i;
|
||||||
unsigned int iCurPos;
|
unsigned int iCurPos;
|
||||||
|
|
||||||
// query length of input vector
|
|
||||||
const int iVecInLenByte = vecIn.Size();
|
|
||||||
|
|
||||||
// vector must be at least "MESS_LEN_WITHOUT_DATA_BYTE" bytes long
|
// vector must be at least "MESS_LEN_WITHOUT_DATA_BYTE" bytes long
|
||||||
if ( iVecInLenByte < MESS_LEN_WITHOUT_DATA_BYTE )
|
if ( iNumBytesIn < MESS_LEN_WITHOUT_DATA_BYTE )
|
||||||
{
|
{
|
||||||
return true; // return error code
|
return true; // return error code
|
||||||
}
|
}
|
||||||
|
@ -968,7 +957,7 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
||||||
iLenBy = static_cast<int> ( GetValFromStream ( vecIn, iCurPos, 2 ) );
|
iLenBy = static_cast<int> ( GetValFromStream ( vecIn, iCurPos, 2 ) );
|
||||||
|
|
||||||
// make sure the length is correct
|
// make sure the length is correct
|
||||||
if ( iLenBy != iVecInLenByte - MESS_LEN_WITHOUT_DATA_BYTE )
|
if ( iLenBy != iNumBytesIn - MESS_LEN_WITHOUT_DATA_BYTE )
|
||||||
{
|
{
|
||||||
return true; // return error code
|
return true; // return error code
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
|
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
|
||||||
|
|
||||||
bool ParseMessage ( const CVector<unsigned char>& vecbyData,
|
bool ParseMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
const int iNumBytes );
|
const int iNumBytes );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -117,6 +117,7 @@ protected:
|
||||||
const int iID );
|
const int iID );
|
||||||
|
|
||||||
bool ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
bool ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
||||||
|
const int iNumBytesIn,
|
||||||
int& iCnt,
|
int& iCnt,
|
||||||
int& iID,
|
int& iID,
|
||||||
CVector<uint8_t>& vecData );
|
CVector<uint8_t>& vecData );
|
||||||
|
|
|
@ -87,16 +87,9 @@ CServer::CServer ( const QString& strLoggingFileName,
|
||||||
|
|
||||||
void CServer::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
|
void CServer::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
|
||||||
{
|
{
|
||||||
|
|
||||||
// convert unsigned uint8_t in char, TODO convert all buffers in uint8_t
|
|
||||||
CVector<unsigned char> vecbyDataConv ( vecMessage.Size() );
|
|
||||||
for ( int i = 0; i < vecMessage.Size (); i++ ) {
|
|
||||||
vecbyDataConv[i] = static_cast<unsigned char> ( vecMessage[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// the protocol queries me to call the function to send the message
|
// the protocol queries me to call the function to send the message
|
||||||
// send it through the network
|
// send it through the network
|
||||||
Socket.SendPacket ( vecbyDataConv, ChannelSet.GetAddress ( iChID ) );
|
Socket.SendPacket ( vecMessage, ChannelSet.GetAddress ( iChID ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::Start()
|
void CServer::Start()
|
||||||
|
|
|
@ -56,7 +56,7 @@ void CSocket::Init ( const quint16 iPortNumber )
|
||||||
this, SLOT ( OnDataReceived() ) );
|
this, SLOT ( OnDataReceived() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
void CSocket::SendPacket ( const CVector<uint8_t>& vecbySendBuf,
|
||||||
const CHostAddress& HostAddr )
|
const CHostAddress& HostAddr )
|
||||||
{
|
{
|
||||||
const int iVecSizeOut = vecbySendBuf.Size();
|
const int iVecSizeOut = vecbySendBuf.Size();
|
||||||
|
@ -65,10 +65,10 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
||||||
{
|
{
|
||||||
// send packet through network (we have to convert the constant unsigned
|
// send packet through network (we have to convert the constant unsigned
|
||||||
// char vector in "const char*", for this we first convert the const
|
// char vector in "const char*", for this we first convert the const
|
||||||
// unsigned char vector in a read/write unsigned char vector and then
|
// uint8_t vector in a read/write uint8_t vector and then do the cast to
|
||||||
// do the cast to const char*)
|
// const char*)
|
||||||
SocketDevice.writeDatagram (
|
SocketDevice.writeDatagram (
|
||||||
(const char*) &( (CVector<unsigned char>) vecbySendBuf )[0],
|
(const char*) &( (CVector<uint8_t>) vecbySendBuf )[0],
|
||||||
iVecSizeOut, HostAddr.InetAddr, HostAddr.iPort );
|
iVecSizeOut, HostAddr.InetAddr, HostAddr.iPort );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,8 @@ void CSocket::OnDataReceived()
|
||||||
quint16 SenderPort;
|
quint16 SenderPort;
|
||||||
|
|
||||||
// read block from network interface and query address of sender
|
// read block from network interface and query address of sender
|
||||||
int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0],
|
const int iNumBytesRead =
|
||||||
|
SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0],
|
||||||
MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort );
|
MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort );
|
||||||
|
|
||||||
// check if an error occurred
|
// check if an error occurred
|
||||||
|
|
16
src/socket.h
16
src/socket.h
|
@ -54,22 +54,22 @@ public:
|
||||||
{ Init ( iPortNumber ); }
|
{ Init ( iPortNumber ); }
|
||||||
virtual ~CSocket() {}
|
virtual ~CSocket() {}
|
||||||
|
|
||||||
void SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
void SendPacket ( const CVector<uint8_t>& vecbySendBuf,
|
||||||
const CHostAddress& HostAddr );
|
const CHostAddress& HostAddr );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER );
|
void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER );
|
||||||
|
|
||||||
QUdpSocket SocketDevice;
|
QUdpSocket SocketDevice;
|
||||||
|
|
||||||
CVector<unsigned char> vecbyRecBuf;
|
CVector<uint8_t> vecbyRecBuf;
|
||||||
CHostAddress RecHostAddr;
|
CHostAddress RecHostAddr;
|
||||||
|
|
||||||
CChannel* pChannel; // for client
|
CChannel* pChannel; // for client
|
||||||
CChannelSet* pChannelSet; // for server
|
CChannelSet* pChannelSet; // for server
|
||||||
|
|
||||||
QObject* pServer;
|
QObject* pServer;
|
||||||
bool bIsClient;
|
bool bIsClient;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnDataReceived();
|
void OnDataReceived();
|
||||||
|
|
Loading…
Add table
Reference in a new issue