This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsock6.h
61 lines (48 loc) · 1.99 KB
/
dsock6.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Copyright 2019 Chris Tallon
This file is part of VOMP.
VOMP is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
VOMP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DSOCK6_H
#define DSOCK6_H
#include <sys/socket.h>
#include <sys/select.h>
#include "defines.h"
#include "log.h"
#define MAXBUFLEN 2000
class DatagramSocket6
{
public:
DatagramSocket6();
~DatagramSocket6();
bool init(USHORT port);
void shutdown();
unsigned char waitforMessage(unsigned char); // int =0-block =1-new wait =2-continue wait
void send(const char *, USHORT, char *, int); // send wants: IP Address ddn style, port,
// data, length of data
char* getData() { return buf; } // returns a pointer to the data
char* getFromIPA() { return fromIPA; } // returns a pointer to from IP address
USHORT getFromPort() const { return fromPort; } // returns the sender port number
int getDataLength() const { return mlength; } // returns data length
private:
Log* log;
int initted;
int socketnum; // Socket descriptor
socklen_t addrlen; // length of sockaddr struct
char buf[MAXBUFLEN]; // main data buffer
char fromIPA[40]; // from string (ip address)
USHORT fromPort; // which port user sent on
int mlength; // length of message
struct timeval tv;
fd_set readfds;
};
#endif