-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet-socket.h
60 lines (52 loc) · 1.82 KB
/
net-socket.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
// net-socket.h
#ifndef NET_SOCKET_H
#define NET_SOCKET_H
#include "socket.h"
#include <rlibrary/rtypestypes.h>
namespace minecraft_controller
{
class network_socket_error { };
class network_socket_address : public socket_address
{
public:
network_socket_address();
network_socket_address(const char* address,const char* portNumber);
virtual ~network_socket_address();
private:
void* _addrInfo; // pointer to address information from getaddrinfo
mutable void* _pWalker; // pointer to current sockaddr structure
virtual void _assignAddress(const char* address,const char* service);
virtual bool _getNextAddress(const void*& address,rtypes::size_type& sz) const;
virtual void _prepareAddressString(char* buffer,rtypes::size_type length) const;
};
class network_socket : public socket
{
public:
network_socket();
~network_socket();
private:
void* _addrbuf;
// implement virtual socket interface
virtual void _openSocket(int& fd);
virtual void _createClientSocket(socket*& socknew);
virtual socket_family _getFamily() const
{ return socket_family_inet; }
virtual void* _getAddressBuffer(rtypes::size_type& length);
virtual void _addressBufferToString(rtypes::str& s) const;
};
class network_socket_stream : public rtypes::rstream,
public rtypes::stream_device<network_socket>
{
public:
network_socket_stream();
network_socket_stream(network_socket&);
~network_socket_stream();
private:
virtual void _clearDevice();
virtual bool _openDevice(const char*);
virtual void _closeDevice();
virtual bool _inDevice() const;
virtual void _outDevice();
};
}
#endif