diff options
author | deva <deva> | 2005-06-02 15:03:23 +0000 |
---|---|---|
committer | deva <deva> | 2005-06-02 15:03:23 +0000 |
commit | 907dbf7e8915fb459e4ab1482fd4dbd8c8ea50d4 (patch) | |
tree | 5c6278093dc03a4b2fe35dc6c8a76aef15eea106 /src/network.cc | |
parent | df793bb0657844c98c0505f47db80798b4ad495e (diff) |
Fixed crash in network.cc if socket not connected.
Added option to skop ecery second frame in player
Diffstat (limited to 'src/network.cc')
-rw-r--r-- | src/network.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/network.cc b/src/network.cc index 05835c0..d21b8fe 100644 --- a/src/network.cc +++ b/src/network.cc @@ -31,6 +31,11 @@ /* * $Log$ + * Revision 1.5 2005/06/02 15:03:23 deva + * + * Fixed crash in network.cc if socket not connected. + * Added option to skop ecery second frame in player + * * Revision 1.4 2005/05/03 08:31:59 deva * Removed the error object, and replaced it with a more generic info object. * @@ -59,8 +64,8 @@ Network::~Network() int Network::write(void *buf, int size) { if(!s->isConnected()) { - info->error("Write attempted to a socket not connected!"); - return 0; + // info->error("Write attempted to a socket not connected!"); + return -1; } int n = send(s->ssocket, buf, size, MSG_WAITALL); @@ -74,8 +79,8 @@ 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!"); - return 0; + // info->error("Read attempted from a socket not connected!"); + return -1; } int n = recv(s->ssocket, buf, size, MSG_WAITALL); @@ -103,6 +108,11 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz) struct msghdr msg; struct iovec iovecs[2]; + if(!s->isConnected()) { + // info->error("Write attempted to a socket not connected!"); + return -1; + } + memset(&msg, 0, sizeof(msg)); msg.msg_iov = iovecs; @@ -128,6 +138,11 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz) struct msghdr msg; struct iovec iovecs[2]; + if(!s->isConnected()) { + // info->error("Read attempted to a socket not connected!"); + return -1; + } + memset(&msg, 0, sizeof(msg)); iovecs[0].iov_base = h; |