cmUdpPort.h/c:Added cmInvalidUdpPortNumber and check for definition of HOST_NAME_MAX.

This commit is contained in:
kevin 2013-05-01 15:08:58 -07:00
parent 0882f93f50
commit 0dd7cdbbe9
2 changed files with 17 additions and 3 deletions

View File

@ -18,6 +18,10 @@
#define cmUdp_SYS_ERR (-1)
#define cmUdp_NULL_SOCK (-1)
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
#endif
enum
{
kIsConnectedUdpFl = 0x01,
@ -100,6 +104,9 @@ cmUdpRC_t _cmUdpInitAddr( cmUdp_t* p, const char* addrStr, cmUdpPort_t portNumbe
{
memset(retAddrPtr,0,sizeof(struct sockaddr_in));
if( portNumber == kInvalidUdpPortNumber )
return cmErrMsg(&p->err,kInvalidPortNumbUdpRC,"The port number %i cannot be used.",kInvalidUdpPortNumber);
if( addrStr == NULL )
retAddrPtr->sin_addr.s_addr = htonl(INADDR_ANY);
else

View File

@ -26,12 +26,13 @@ extern "C" {
kRecvBufOverflowUdpRC,
kBufTooSmallUdpRC,
kHostNameFailUdpRC,
kInvalidPortNumbUdpRC,
kTimeOutUdpRC
};
typedef cmRC_t cmUdpRC_t;
typedef cmHandle_t cmUdpH_t;
typedef u_short cmUdpPort_t;
typedef cmRC_t cmUdpRC_t;
typedef cmHandle_t cmUdpH_t;
typedef unsigned short cmUdpPort_t;
extern cmUdpH_t cmUdpNullHandle;
@ -46,6 +47,12 @@ extern "C" {
};
enum
{
// port 0 is reserved by and is therefore a convenient invalid port number
kInvalidUdpPortNumber = 0
};
cmUdpRC_t cmUdpAlloc( cmCtx_t* ctx, cmUdpH_t* hp );
cmUdpRC_t cmUdpFree( cmUdpH_t* hp );