-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsocket.hh
More file actions
34 lines (25 loc) · 691 Bytes
/
socket.hh
File metadata and controls
34 lines (25 loc) · 691 Bytes
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
#ifndef SOCKET_HH
#define SOCKET_HH
#include "address.hh"
#include "packet.hh"
namespace Network {
/* Socket class. Wraps socket() */
class Socket {
private:
int sock_; /* the socket file descriptor */
public:
/* Default constructor */
Socket();
/* Bind to port (typically used by server) */
void bind( const Address & addr ) const;
/* Connect to ip/port (typically used by client) */
void connect( const Address & addr ) const;
/* Send packet */
void send( Packet & packet ) const;
/* Receive a packet */
Packet recv( void ) const;
/* Getter for underlying socket fd */
int fd( void ) const { return sock_; }
};
}
#endif