From e2f4514a4530e0b5c4eb270bab970ab9391b5085 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 6 Aug 2011 01:00:30 +0300 Subject: [PATCH] Remove the now-obsolete check_state method --- source/datagramsocket.cpp | 6 ------ source/socket.cpp | 15 +++++---------- source/socket.h | 1 - source/streamsocket.cpp | 3 --- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/source/datagramsocket.cpp b/source/datagramsocket.cpp index e15a1d1..1368d15 100644 --- a/source/datagramsocket.cpp +++ b/source/datagramsocket.cpp @@ -17,8 +17,6 @@ DatagramSocket::DatagramSocket(Family f, int p): int DatagramSocket::connect(const SockAddr &addr) { - check_state(false); - sockaddr_storage sa; socklen_t size = addr.fill_sockaddr(sa); @@ -47,8 +45,6 @@ int DatagramSocket::connect(const SockAddr &addr) unsigned DatagramSocket::sendto(const char *buf, unsigned size, const SockAddr &addr_) { - check_state(false); - if(size==0) return 0; @@ -75,8 +71,6 @@ unsigned DatagramSocket::sendto(const char *buf, unsigned size, const SockAddr & unsigned DatagramSocket::recvfrom(char *buf, unsigned size, SockAddr *&addr_) { - check_state(false); - if(size==0) return 0; diff --git a/source/socket.cpp b/source/socket.cpp index 7bccec6..b6ab2e8 100644 --- a/source/socket.cpp +++ b/source/socket.cpp @@ -108,8 +108,6 @@ const IO::Handle &Socket::get_event_handle() void Socket::bind(const SockAddr &addr) { - check_state(false); - sockaddr_storage sa; unsigned size = addr.fill_sockaddr(sa); @@ -148,12 +146,6 @@ const SockAddr &Socket::get_peer_address() const return *peer_addr; } -void Socket::check_state(bool conn) const -{ - if(conn && !connected) - throw bad_socket_state("not connected"); -} - int Socket::set_option(int level, int optname, const void *optval, socklen_t optlen) { #ifdef WIN32 @@ -174,7 +166,8 @@ int Socket::get_option(int level, int optname, void *optval, socklen_t *optlen) unsigned Socket::do_write(const char *buf, unsigned size) { - check_state(true); + if(!connected) + throw bad_socket_state("not connected"); if(size==0) return 0; @@ -193,7 +186,9 @@ unsigned Socket::do_write(const char *buf, unsigned size) unsigned Socket::do_read(char *buf, unsigned size) { - check_state(true); + if(!connected) + throw bad_socket_state("not connected"); + if(size==0) return 0; diff --git a/source/socket.h b/source/socket.h index dbe3151..6eb2906 100644 --- a/source/socket.h +++ b/source/socket.h @@ -49,7 +49,6 @@ public: const SockAddr &get_local_address() const; const SockAddr &get_peer_address() const; protected: - void check_state(bool) const; int set_option(int, int, const void *, socklen_t); int get_option(int, int, void *, socklen_t *) const; unsigned do_write(const char *, unsigned); diff --git a/source/streamsocket.cpp b/source/streamsocket.cpp index cd810d5..5959084 100644 --- a/source/streamsocket.cpp +++ b/source/streamsocket.cpp @@ -27,7 +27,6 @@ StreamSocket::StreamSocket(Family af, int proto): int StreamSocket::poll_connect(const Time::TimeDelta &timeout) { - check_state(false); if(!connecting) throw bad_socket_state("not connecting"); @@ -71,8 +70,6 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout) int StreamSocket::connect(const SockAddr &addr) { - check_state(false); - if(connected) throw bad_socket_state("already connected"); -- 2.45.2