/*************************************************************************** rludpsocket.h - description ------------------- begin : Tue Apr 03 2007 copyright : (C) 2007 by R. Lehrig email : lehrig@t-online.de ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * * published by the Free Software Foundation * * * ***************************************************************************/ #ifndef _RL_UDP_SOCKET_H_ #define _RL_UDP_SOCKET_H_ #include "rldefine.h" #include "rlsocket.h" #ifdef RLWIN32 #include #include #include #include #define MSG_NOSIGNAL 0 #else #include #include #include #include #include #include "unistd.h" #endif /*!
class for encapsulating ip  addresses
*/ class rlIpAdr { public: rlIpAdr(); virtual ~rlIpAdr(); int setAdr(const char *adr, int port); int operator== (rlIpAdr &address1); struct sockaddr_in address; }; /*!
class for encapsulating UDP socket calls
*/ class rlUdpSocket { public: rlUdpSocket(int debug = 0); virtual ~rlUdpSocket(); /*!
  setsocketopt for SOL_SOCKET level
  
*/ int setSockopt(int opt); /*!
  setsocketopt with full control
  
*/ int setSockopt(int level, int optname, void *optval, int optlen); /*!
  return > 0 -> socket else error
  
*/ int bind(int port); /*!
  return == 0 -> timeout
  
*/ int select(int timeout); /*!
  return > 0 -> number of bytes read return == 0 -> timeout else error
  
*/ int recvfrom(void *buf, int maxlen, rlIpAdr *source, int timeout = -1); /*!
  return >= 0 -> number of bytes written else error
  
*/ int sendto(const void *buf, int len, rlIpAdr *dest); /*!
  return >= 0 -> number of bytes written else error
  
*/ int printf(rlIpAdr *dest, const char *format, ...); int debug, readflag, writeflag; private: struct sockaddr_in address; int s; }; #endif