Purpose: Write buffer content to a socket

Return TypeFunction nameArguments
hzEcodehzUdpClient::SendPkt(hzPacket*,uint32_t,)

Declared in file: hzUdpClient.h
Defined in file : hzUdpClient.cpp

Function Logic:

0:START 1:unknown 2:Return E_NOSOCKET 3:unknown 4:items 5:Return E_ARGUMENT 6:unknown 7:items 8:Return E_RANGE 9:unknown 10:items m_nSock items 11:Return E_SENDFAIL 12:items 13:Return E_OK

Function body:

hzEcode hzUdpClient::SendPkt (hzPacket* pData)uint32_t nLen, 
{
   //  Purpose: Write buffer content to a socket
   //  
   //  Arguments: 1) pData The buffer (void*)
   //     2) nLen Number of bytes to send
   //  
   //  Returns: E_NOSOCKET If no socket has been set by Connect()
   //     E_ARGUMENT If the data is not provided
   //     E_RANGE  If the number of bytes to send exceeds packet size (1460 bytes)
   //     E_SENDFAIL If the send operation fails. In this event the connection is closed.
   //     E_OK  If the operation is successfull.
   _hzfunc("hzUdpClient::Send(void*,uint32_t)") ;
   if (m_nSock == 0)
       return E_NOSOCKET ;
   if (!pData)
   {
       hzerr(E_ARGUMENT, "Nothing to send") ;
       return E_ARGUMENT ;
   }
   if (nLen > HZ_MAXPACKET)
   {
       hzerr(E_RANGE, "Length of message must be between 1 and 1460 bytes") ;
       return E_RANGE ;
   }
   //  send a message
   if (sendto(m_nSock, pData->m_data, nLen, 0,(struct sockaddr*) &m_SvrAddr, m_SvrLen) < 0)
   {
       close(m_nSock) ;
       m_nSock = 0;
       hzerr(E_SENDFAIL, "Could not send to host (%s) on port %d", *m_Hostname, m_nPort) ;
       return E_SENDFAIL ;
   }
   threadLog("Client sock %d sends msg of %d bytes [%s]\n", m_nSock, nLen, pData->m_data) ;
   return E_OK ;
}