From d6ee7ec642cc6b3097c8d321a1a00630e24027d1 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 16 Feb 2008 12:22:33 +0000 Subject: initial client-to-server connection --- src/net/tcpconnection.cc | 16 ++++++++-------- src/net/tcpconnection.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/net') diff --git a/src/net/tcpconnection.cc b/src/net/tcpconnection.cc index 92bc3d2..e4ff009 100644 --- a/src/net/tcpconnection.cc +++ b/src/net/tcpconnection.cc @@ -83,10 +83,10 @@ void TCPConnection::disconnect() tcpconnection_error = false; tcpconnection_host.clear(); tcpconnection_port = 0; - con_debug << "Network disconnected from server" << std::endl; + //con_debug << "Network disconnected from server" << std::endl; } -void TCPConnection::connect(std::string to_host, int to_port) +void TCPConnection::connect(std::string const &to_host, int to_port) { if (valid()) return; @@ -95,7 +95,7 @@ void TCPConnection::connect(std::string to_host, int to_port) struct hostent *serverhostent; serverhostent = gethostbyname(to_host.c_str()); if (!serverhostent) { - con_warn << "Network can't resolve " << to_host.c_str() << "!" << std::endl; + con_warn << "Could not resolve '" << to_host.c_str() << "'" << std::endl; abort(); return; } @@ -105,7 +105,7 @@ void TCPConnection::connect(std::string to_host, int to_port) // Get a socket file descriptor tcpconnection_fd = socket(PF_INET, SOCK_STREAM, 0); if (tcpconnection_fd == -1) { - con_error << "Network socket() failed!" << std::endl; + //con_error << "Network socket() failed!" << std::endl; abort(); return; } @@ -118,7 +118,7 @@ void TCPConnection::connect(std::string to_host, int to_port) memset(server_addr.sin_zero, '\0', sizeof server_addr.sin_zero); if (::connect(tcpconnection_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) != 0) { - con_error << "Network connect() failed!" << std::endl; + //con_error << "Network connect() failed!" << std::endl; abort(); return; } @@ -126,7 +126,7 @@ void TCPConnection::connect(std::string to_host, int to_port) tcpconnection_host = to_host; tcpconnection_port = to_port; tcpconnection_error = false; - con_print << "Connected to server." << std::endl; + //con_print << "Connected to server." << std::endl; } @@ -147,7 +147,7 @@ void TCPConnection::receive(std::string &msg) return; } else if (bytes_received < 0) { con_error << "Network receive() error!" << std::endl; - perror("recv"); + //perror("recv"); abort(); return; } @@ -172,7 +172,7 @@ void TCPConnection::send(std::string const &msg) bytes_sent = ::send(tcpconnection_fd, sendbuf.c_str(), sendbuf.size(), 0); if (bytes_sent < 0) { con_error << "Network send() error!" << std::endl; - perror("send"); + //perror("send"); abort(); return; } diff --git a/src/net/tcpconnection.h b/src/net/tcpconnection.h index 7e71ed0..6076215 100644 --- a/src/net/tcpconnection.h +++ b/src/net/tcpconnection.h @@ -46,7 +46,7 @@ public: int fd() const; /// connect to a remote host - virtual void connect(std::string to_host, int to_port); + virtual void connect(std::string const &to_host, int to_port); /// disconnect from a remote host virtual void disconnect(); -- cgit v1.2.3