]> git.tdb.fi Git - libs/net.git/blobdiff - source/socket.cpp
Remove the now-obsolete check_state method
[libs/net.git] / source / socket.cpp
index 7bccec6de1303997f07883898ea947b99fd12ba4..b6ab2e8edac2e49b2a1a203d66b25b85a2b27e81 100644 (file)
@@ -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;