diff options
author | deva <deva> | 2006-01-10 10:03:41 +0000 |
---|---|---|
committer | deva <deva> | 2006-01-10 10:03:41 +0000 |
commit | 495330ce3cfb6b168d2fb9b56aa125bbc7ff6e7d (patch) | |
tree | 45cb7dc618e05a21657790e17b617a664652dae1 /src/aa_socket.h | |
parent | caa558e59c248521d1d4ad483fe669828277664e (diff) |
*** empty log message ***
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..0d02723 --- /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(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__*/ |