]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Better handling of SendFailedException in Connection
authorPerttu Ahola <celeron55@gmail.com>
Tue, 18 Oct 2011 00:42:23 +0000 (03:42 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 18 Oct 2011 00:42:23 +0000 (03:42 +0300)
src/connection.cpp
src/socket.cpp
src/socket.h

index 0f09753bd413dbfd8453522b093595adb09c1da9..623994c4c043785ca8e2255cd090b8585c939362 100644 (file)
@@ -1104,8 +1104,6 @@ u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
        }
        catch(SendFailedException &e)
        {
-               derr_con<<"Receive(): SendFailedException; peer_id="
-                               <<peer_id<<std::endl;
        }
        } // for
 }
@@ -1195,7 +1193,12 @@ void Connection::SendAsPacket(u16 peer_id, u8 channelnum,
 
 void Connection::RawSend(const BufferedPacket &packet)
 {
-       m_socket.Send(packet.address, *packet.data, packet.data.getSize());
+       try{
+               m_socket.Send(packet.address, *packet.data, packet.data.getSize());
+       } catch(SendFailedException &e){
+               derr_con<<"Connection::RawSend(): SendFailedException: "
+                               <<packet.address.serializeString()<<std::endl;
+       }
 }
 
 void Connection::RunTimeouts(float dtime)
index ac4871f6145524059f4ed73b1d2de0a1864a7f59..6d48178f963504c24075e270bc945da31ef3a25f 100644 (file)
@@ -97,7 +97,7 @@ void Address::Resolve(const char *name)
        freeaddrinfo(resolved);
 }
 
-std::string Address::serializeString()
+std::string Address::serializeString() const
 {
        unsigned int a, b, c, d;
        a = (m_address & 0xFF000000)>>24;
index f24947c2785b10341d361514e989f52c12c9c617..74b5fb64391173c6142ccbd95c3e3bd3606022f7 100644 (file)
@@ -97,7 +97,7 @@ class Address
        void setPort(unsigned short port);
        void print(std::ostream *s) const;
        void print() const;
-       std::string serializeString();
+       std::string serializeString() const;
 private:
        unsigned int m_address;
        unsigned short m_port;