From f02095ee5ceb78f1781a9e250693b8866ca42181 Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 4 Mar 2006 14:53:17 +0000 Subject: *** empty log message *** --- lib/aa_socket.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/aa_socket.h (limited to 'lib/aa_socket.h') diff --git a/lib/aa_socket.h b/lib/aa_socket.h new file mode 100644 index 0000000..0d02723 --- /dev/null +++ b/lib/aa_socket.h @@ -0,0 +1,42 @@ +#ifndef __SOCKET_H__ +#define __SOCKET_H__ + +#include + +#include +//#include + + +/** + * Exceptions + */ +struct Network_error { + Network_error(char *event, 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(char *ip, unsigned short port); + + void send(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__*/ -- cgit v1.2.3