rllib  1
rludpsocket.h
Go to the documentation of this file.
1 /***************************************************************************
2  rludpsocket.h - description
3  -------------------
4  begin : Tue Apr 03 2007
5  copyright : (C) 2007 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #ifndef _RL_UDP_SOCKET_H_
17 #define _RL_UDP_SOCKET_H_
18 
19 #include "rldefine.h"
20 #include "rlsocket.h"
21 
22 #ifdef RLWIN32
23 #include <winsock2.h>
24 #include <windows.h>
25 #include <io.h>
26 #include <direct.h>
27 #define MSG_NOSIGNAL 0
28 #else
29 #include <sys/time.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33 #include <netdb.h>
34 #include "unistd.h"
35 #endif
36 
40 class rlIpAdr
41 {
42 public:
43  rlIpAdr();
44  virtual ~rlIpAdr();
45  int setAdr(const char *adr, int port);
46  int operator== (rlIpAdr &address1);
47  struct sockaddr_in address;
48 };
49 
54 {
55 public:
56  rlUdpSocket(int debug = 0);
57  virtual ~rlUdpSocket();
58 
62  int setSockopt(int opt);
63 
67  int setSockopt(int level, int optname, void *optval, int optlen);
68 
72  int bind(int port);
73 
77  int select(int timeout);
78 
82  int recvfrom(void *buf, int maxlen, rlIpAdr *source, int timeout = -1);
83 
87  int sendto(const void *buf, int len, rlIpAdr *dest);
88 
92  int printf(rlIpAdr *dest, const char *format, ...);
93 
95 
96 private:
97  struct sockaddr_in address;
98  int s;
99 };
100 
101 #endif
virtual ~rlIpAdr()
Definition: rludpsocket.cpp:27
int recvfrom(void *buf, int maxlen, rlIpAdr *source, int timeout=-1)
int setSockopt(int opt)
Definition: rludpsocket.cpp:98
int printf(rlIpAdr *dest, const char *format,...)
int setAdr(const char *adr, int port)
Definition: rludpsocket.cpp:31
int select(int timeout)
int bind(int port)
int operator==(rlIpAdr &address1)
Definition: rludpsocket.cpp:63
struct sockaddr_in address
Definition: rludpsocket.h:97
int sendto(const void *buf, int len, rlIpAdr *dest)
virtual ~rlUdpSocket()
Definition: rludpsocket.cpp:86
rlUdpSocket(int debug=0)
Definition: rludpsocket.cpp:72
struct sockaddr_in address
Definition: rludpsocket.h:47