diff options
author | deva <deva> | 2006-08-25 21:20:07 +0000 |
---|---|---|
committer | deva <deva> | 2006-08-25 21:20:07 +0000 |
commit | 8196872e3b240ef93fc17dd3c05a7d97a8015d88 (patch) | |
tree | e531edeb1c7178a8e58170c84645ce8eb706624e /lib/network.cc | |
parent | 347b1d8ed3a4f780f3a5c0d57a04eab05ca517a2 (diff) |
Rearranged the network and socket code.origin
Added status messages sent over the network using udp packets.
Diffstat (limited to 'lib/network.cc')
-rw-r--r-- | lib/network.cc | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/lib/network.cc b/lib/network.cc index cb3f94e..4957bb6 100644 --- a/lib/network.cc +++ b/lib/network.cc @@ -50,11 +50,11 @@ Network::~Network() int Network::write(void *buf, int size) { - if(!s->isConnected()) { + if(!s->connected) { // MIaV::info->error("Write attempted to a socket not connected!"); return -1; } - int n = send(s->ssocket, buf, size, MSG_WAITALL); + int n = send(s->sock, buf, size, MSG_WAITALL); if(n == -1) { MIaV::info->error("An error occurred!"); @@ -65,11 +65,11 @@ int Network::write(void *buf, int size) int Network::read(void *buf, int size) { - if(!s->isConnected()) { + if(!s->connected) { // MIaV::info->error("Read attempted from a socket not connected!"); return -1; } - int n = recv(s->ssocket, buf, size, MSG_WAITALL); + int n = recv(s->sock, buf, size, MSG_WAITALL); if(n == -1) { MIaV::info->error("An error occurred!"); @@ -95,7 +95,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz) struct msghdr msg; struct iovec iovecs[2]; - if(!s->isConnected()) { + if(!s->connected) { // MIaV::info->error("Write attempted to a socket not connected!"); return -1; } @@ -111,7 +111,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz) msg.msg_iov[1].iov_base = buf; msg.msg_iov[1].iov_len = bufsz; - int n = sendmsg(s->ssocket, &msg, 0); + int n = sendmsg(s->sock, &msg, 0); if(n < 0) { MIaV::info->error("A network error ocurred during sendPackage!"); return -1; @@ -125,7 +125,7 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz) struct msghdr msg; struct iovec iovecs[2]; - if(!s->isConnected()) { + if(!s->connected) { // MIaV::info->error("Read attempted to a socket not connected!"); return -1; } @@ -141,7 +141,7 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz) msg.msg_iov = iovecs; msg.msg_iovlen = 2; - int n = recvmsg(s->ssocket, &msg, MSG_WAITALL); + int n = recvmsg(s->sock, &msg, MSG_WAITALL); if(n < 0) { MIaV::info->error("A network error ocurred during recvPackage!"); @@ -161,7 +161,7 @@ int Network::sendFrame(Frame *frame) struct msghdr msg; struct iovec iovecs[2]; - if(!s->isConnected()) { + if(!s->connected) { // MIaV::info->error("Write attempted to a socket not connected!"); return -1; } @@ -196,7 +196,7 @@ int Network::sendFrame(Frame *frame) msg.msg_iov[1].iov_base = aframe; msg.msg_iov[1].iov_len = aframesize; - int n = sendmsg(s->ssocket, &msg, 0); + int n = sendmsg(s->sock, &msg, 0); if(n < 0) { MIaV::info->error("A network error ocurred during sendPackage!"); @@ -215,7 +215,7 @@ Frame *Network::recvFrame() struct msghdr msg; struct iovec iovecs[2]; - if(!s->isConnected()) { + if(!s->connected) { // MIaV::info->error("Read attempted to a socket not connected!"); return NULL; } @@ -239,7 +239,7 @@ Frame *Network::recvFrame() msg.msg_iov = iovecs; msg.msg_iovlen = 2; - int n = recvmsg(s->ssocket, &msg, MSG_WAITALL); + int n = recvmsg(s->sock, &msg, MSG_WAITALL); if(n < 0) { MIaV::info->error("A network error ocurred during recvPackage!"); @@ -269,18 +269,3 @@ Frame *Network::recvFrame() return frame; } -int Network::sendStatus(Status *status) -{ - return 0; -} - -int Network::recvStatus(Status *status) -{ - /* - status.diskspace = 10; - status.diskspace_max = 100; - status.load = 80; - status.load_max = 100; - */ - return 0; -} |