Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/tcpclient.cc2
-rw-r--r--src/net/tcpconnection.cc2
-rw-r--r--src/net/tcpserver.cc13
-rw-r--r--src/net/tcpserver.h5
4 files changed, 13 insertions, 9 deletions
diff --git a/src/net/tcpclient.cc b/src/net/tcpclient.cc
index da5ff27..b8aa9dd 100644
--- a/src/net/tcpclient.cc
+++ b/src/net/tcpclient.cc
@@ -27,7 +27,7 @@ TCPClient::~TCPClient()
{
if (tcpclient_fd != -1)
close(tcpclient_fd);
-
+ //con_debug << "TCPClient: terminated." << std::endl;
}
bool TCPClient::error() const
diff --git a/src/net/tcpconnection.cc b/src/net/tcpconnection.cc
index 9eaba1f..92bc3d2 100644
--- a/src/net/tcpconnection.cc
+++ b/src/net/tcpconnection.cc
@@ -142,7 +142,7 @@ void TCPConnection::receive(std::string &msg)
memset(recvbuf, '\0', sizeof(recvbuf));
bytes_received = ::recv(tcpconnection_fd, recvbuf, msglen, 0);
if (bytes_received == 0) {
- con_print << "Server disconnected.";
+ con_print << "Disconnected.";
abort();
return;
} else if (bytes_received < 0) {
diff --git a/src/net/tcpserver.cc b/src/net/tcpserver.cc
index f194a63..3276f87 100644
--- a/src/net/tcpserver.cc
+++ b/src/net/tcpserver.cc
@@ -27,9 +27,9 @@ TCPServer::TCPServer(std::string const host, unsigned int const port)
{
tcpserver_fd = -1;
tcpserver_error = true;
-
- con_debug << "TCPServer: starting." << std::endl;
-
+
+ con_print << "Initializing network..." << std::endl;
+
// initialize socket
tcpserver_fd = ::socket(PF_INET, SOCK_STREAM, 0);
if (tcpserver_fd == -1) {
@@ -73,7 +73,7 @@ TCPServer::TCPServer(std::string const host, unsigned int const port)
}
tcpserver_error = false;
- con_print << "Listening on " << inet_ntoa(listen_addr.sin_addr) <<
+ con_print << " listening on " << inet_ntoa(listen_addr.sin_addr) <<
":" << ntohs(listen_addr.sin_port) << std::endl;
}
@@ -81,7 +81,7 @@ TCPServer::~TCPServer()
{
if (tcpserver_fd != -1)
::close(tcpserver_fd);
- con_debug << "TCPServer: terminated." << std::endl;
+ //con_debug << "TCPServer: terminated." << std::endl;
}
bool TCPServer::valid() const
@@ -111,7 +111,7 @@ void TCPServer::abort()
void TCPServer::accept()
{
- con_debug << "TCPServer: accept()" << std::endl;
+ //con_debug << "TCPServer: accept()" << std::endl;
struct sockaddr_in client_addr;
socklen_t addrlen = sizeof(struct sockaddr_in);
@@ -129,3 +129,4 @@ void TCPServer::accept()
}
}
+
diff --git a/src/net/tcpserver.h b/src/net/tcpserver.h
index dd87689..99639eb 100644
--- a/src/net/tcpserver.h
+++ b/src/net/tcpserver.h
@@ -32,12 +32,15 @@ public:
bool error() const;
protected:
- /// Accept incoming connections
+ /// accept an incoming connection
void accept();
+
/// Set the error state
void abort();
+
/// Returns the file descriptor the TCP server is listening on
int fd() const;
+
/// Called by accept() whenever a new client connects
virtual void client_connect(int const clientfd, std::string const host, int const port) = 0;