summaryrefslogtreecommitdiff
path: root/src/network.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-05-28 15:05:57 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-05-28 15:05:57 +0200
commit0332e496347f6b563abb86d4ef9650bbd6ebc3e1 (patch)
tree74dadbe6e4f3216c8a3c8570e203aad0187febf3 /src/network.cc
parent8eb0759e2e8a5405b2dd9e6d72d3bd620b51bee4 (diff)
Port server to hugin.
Diffstat (limited to 'src/network.cc')
-rw-r--r--src/network.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/network.cc b/src/network.cc
index 50ff810..4196cc9 100644
--- a/src/network.cc
+++ b/src/network.cc
@@ -32,9 +32,10 @@
#include <string.h>
#include <sys/socket.h>
-Network::Network(Socket *gs, Info *ginfo)
+#include <hugin.hpp>
+
+Network::Network(Socket *gs)
{
- info = ginfo;
s = gs;
}
@@ -45,13 +46,13 @@ Network::~Network()
int Network::write(void *buf, int size)
{
if(!s->isConnected()) {
- // info->error("Write attempted to a socket not connected!");
+ ERR(network, "Write attempted to a socket not connected!");
return -1;
}
int n = send(s->ssocket, buf, size, MSG_WAITALL);
if(n == -1) {
- info->error("An error occurred!");
+ ERR(network, "An error occurred!");
}
return n;
@@ -60,13 +61,13 @@ int Network::write(void *buf, int size)
int Network::read(void *buf, int size)
{
if(!s->isConnected()) {
- // info->error("Read attempted from a socket not connected!");
+ ERR(network, "Read attempted from a socket not connected!");
return -1;
}
int n = recv(s->ssocket, buf, size, MSG_WAITALL);
if(n == -1) {
- info->error("An error occurred!");
+ ERR(network, "An error occurred!");
}
return n;
@@ -90,7 +91,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz)
struct iovec iovecs[2];
if(!s->isConnected()) {
- // info->error("Write attempted to a socket not connected!");
+ ERR(network, "Write attempted to a socket not connected!");
return -1;
}
@@ -108,7 +109,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz)
int n = sendmsg(s->ssocket, &msg, 0);
if(n < 0) {
perror(" sendmsg(s->ssocket, &msg, 0): ");
- info->error("A network error ocurred during sendPackage!");
+ ERR(network, "A network error ocurred during sendPackage!");
return -1;
}
@@ -121,7 +122,7 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz)
struct iovec iovecs[2];
if(!s->isConnected()) {
- // info->error("Read attempted to a socket not connected!");
+ ERR(network, "Read attempted to a socket not connected!");
return -1;
}
@@ -139,12 +140,12 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz)
int n = recvmsg(s->ssocket, &msg, MSG_WAITALL);
if(n < 0) {
- info->error("A network error ocurred during recvPackage!");
+ ERR(network, "A network error ocurred during recvPackage!");
return -1;
}
if(msg.msg_iovlen != 2) {
- info->error("Wrong package format!");
+ ERR(network, "Wrong package format!");
return -1;
}
return n;