summaryrefslogtreecommitdiff
path: root/src/network.cc
diff options
context:
space:
mode:
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;