cmUdpPort.h/c:Added cmInvalidUdpPortNumber and check for definition of HOST_NAME_MAX.
This commit is contained in:
parent
0882f93f50
commit
0dd7cdbbe9
@ -18,6 +18,10 @@
|
|||||||
#define cmUdp_SYS_ERR (-1)
|
#define cmUdp_SYS_ERR (-1)
|
||||||
#define cmUdp_NULL_SOCK (-1)
|
#define cmUdp_NULL_SOCK (-1)
|
||||||
|
|
||||||
|
#ifndef HOST_NAME_MAX
|
||||||
|
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
kIsConnectedUdpFl = 0x01,
|
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));
|
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 )
|
if( addrStr == NULL )
|
||||||
retAddrPtr->sin_addr.s_addr = htonl(INADDR_ANY);
|
retAddrPtr->sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
else
|
else
|
||||||
|
@ -26,12 +26,13 @@ extern "C" {
|
|||||||
kRecvBufOverflowUdpRC,
|
kRecvBufOverflowUdpRC,
|
||||||
kBufTooSmallUdpRC,
|
kBufTooSmallUdpRC,
|
||||||
kHostNameFailUdpRC,
|
kHostNameFailUdpRC,
|
||||||
|
kInvalidPortNumbUdpRC,
|
||||||
kTimeOutUdpRC
|
kTimeOutUdpRC
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef cmRC_t cmUdpRC_t;
|
typedef cmRC_t cmUdpRC_t;
|
||||||
typedef cmHandle_t cmUdpH_t;
|
typedef cmHandle_t cmUdpH_t;
|
||||||
typedef u_short cmUdpPort_t;
|
typedef unsigned short cmUdpPort_t;
|
||||||
|
|
||||||
extern cmUdpH_t cmUdpNullHandle;
|
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 cmUdpAlloc( cmCtx_t* ctx, cmUdpH_t* hp );
|
||||||
cmUdpRC_t cmUdpFree( cmUdpH_t* hp );
|
cmUdpRC_t cmUdpFree( cmUdpH_t* hp );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user