diff options
Diffstat (limited to 'src/core/netconnection.h')
-rw-r--r-- | src/core/netconnection.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/core/netconnection.h b/src/core/netconnection.h index 7623e64..f378afb 100644 --- a/src/core/netconnection.h +++ b/src/core/netconnection.h @@ -7,19 +7,30 @@ #ifndef __INCLUDED_CORE_NETCONNECTION_H__ #define __INCLUDED_CORE_NETCONNECTION_H__ +#include <unistd.h> +#include <errno.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/wait.h> + +#include <netinet/in.h> +#include <arpa/inet.h> + #include <sys/select.h> +#include <netdb.h> #include <string> #include <deque> #include <map> -#include "net/tcpconnection.h" +#include "core/net.h" namespace core { /// a client to server connection -class NetConnection : public net::TCPConnection +class NetConnection { public: NetConnection(); @@ -40,6 +51,22 @@ public: /// send bufered outgoing data void transmit(); + void abort(); + + inline int fd() const { return connection_fd; } + + inline std::string host() const { return connection_host; } + + inline int port() const { return connection_port; } + + inline bool valid() const { return (connection_fd != -1); } + + inline bool invalid() const { return (connection_fd == -1); } + + inline bool error() const { return connection_error; } + + inline bool connected() const { return ((connection_fd != -1) && !connection_error); } + protected: /// receive incoming data and store messages void receive(); @@ -58,6 +85,13 @@ private: std::deque<std::string> recvq; std::string sendq; fd_set clientset; + + int connection_fd; + bool connection_error; + std::string connection_host; + int connection_port; + struct sockaddr_in server_addr; + char recvbuf[BLOCKSIZE]; }; } |