diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-05-21 14:51:02 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-05-21 14:51:02 +0200 | 
| commit | 65f196f0c5758018cb738fee6fbae088d513b3bd (patch) | |
| tree | 29a5313fce6e3f5f6572fa49116b7597a02d87f8 /src/aa_socket.h | |
| parent | 77a0868116fdfb465d3834a81edb93b1605674b1 (diff) | |
Missing file for cprlistener.
Diffstat (limited to 'src/aa_socket.h')
| -rw-r--r-- | src/aa_socket.h | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/src/aa_socket.h b/src/aa_socket.h new file mode 100644 index 0000000..8b077f3 --- /dev/null +++ b/src/aa_socket.h @@ -0,0 +1,42 @@ +#ifndef __SOCKET_H__ +#define __SOCKET_H__ + +#include <string> + +#include <netinet/in.h> +//#include <sys/socket.h> + + +/** + * Exceptions + */ +struct Network_error { +	Network_error(const char *event, const char *err) { +		error = std::string(err) + " - in " + std::string(event); +	} +	std::string error; +}; + +class AASocket { +public: +  AASocket(); +  ~AASocket(); + +  void listen(unsigned short port); +  void connect(const char *ip, unsigned short port); +   +  void send(const char* buf, unsigned int buf_size); +  int receive(char* buf, unsigned int buf_size); + +  void send_string(std::string buf); +  std::string receive_string(); + +	void force_close(); + +private: +  struct sockaddr_in socketaddr; +  int socket; +	int bind_socket; // Tmp socket for listen. +}; + +#endif/*__SOCKET_H__*/ | 
