-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudpclient.hpp
executable file
·43 lines (34 loc) · 1.05 KB
/
udpclient.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <ipc/genericio.h>
#include <datatypes.h>
#ifndef UDPCLIENT_HPP
#define UDPCLIENT_HPP
class UDPClient : GenericIO {
protected:
int sock;
struct sockaddr_in cpy;
public:
UDPClient();
virtual ~UDPClient();
int getSocket();
void bindService(const char *);
void setupBroadcast(const char *); // broadcast on a port
void setSockaddr(struct sockaddr_in *);
static void makeRecipient(struct sockaddr_in *server, const char *, const char *);
int setNonBlocking(int);
int readMessage(BYTE *, int);
int sendMessage(BYTE *, int);
int sendMessage(BYTE *, int, struct sockaddr_in *);
int sendMessage(const char *buf) { return sendMessage((BYTE *)buf, strlen(buf)); }
int sendMessage(const char *buf,struct sockaddr_in *srv) { return(sendMessage((BYTE *)buf,strlen(buf),srv)); }
};
#endif