1 #ifndef __UDP_H__
2 #define __UDP_H__
3 
4 // since Win32 also defines these, we create definitions for these on other platforms
5 #ifndef WIN32
6 #define closesocket close
7 #define WSAGetLastError() errno
8 #define SOCKET int
9 #define INVALID_SOCKET -1
10 #endif
11 
12 struct UdpOutgoing {
13 	SOCKADDR_STORAGE to;
14 	uint len;
15 	byte mem[1];
16 };
17 
18 // this must be a power of 2.
19 #define UDP_OUTGOING_SIZE 32
20 
21 class UDPSocketManager {
22 public:
23 	SOCKET _socket;
24 
25 	int pos,count;
26 	UdpOutgoing *buff[UDP_OUTGOING_SIZE];
27 
28 	UDPSocketManager();
29 
30 	void set_socket(SOCKET s);
31 	void select(int microsec);
32 	void Send(const byte *p, size_t len, const struct sockaddr *to, socklen_t tolen);
33 	void Flush();
34 };
35 
36 #endif //__UDP_H__
37