Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-21 19:25:11 +0000
committerStijn Buys <ingar@osirion.org>2008-03-21 19:25:11 +0000
commit2314c27dd650dc02c0b5bdd3bef75818393a9ab5 (patch)
tree231815c866a1330338d976480284250e99207554 /src/core/netconnection.h
parent7e99fac4552b402034e5fc3e833cbe8c274f95ce (diff)
switched to UDP networking
Diffstat (limited to 'src/core/netconnection.h')
-rw-r--r--src/core/netconnection.h38
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];
};
}