Better handling of SendFailedException in Connection

master
Perttu Ahola 2011-10-18 03:42:23 +03:00
parent 22b07bdb30
commit 85002883bd
3 changed files with 8 additions and 5 deletions

View File

@ -1104,8 +1104,6 @@ u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
} }
catch(SendFailedException &e) catch(SendFailedException &e)
{ {
derr_con<<"Receive(): SendFailedException; peer_id="
<<peer_id<<std::endl;
} }
} // for } // for
} }
@ -1195,7 +1193,12 @@ void Connection::SendAsPacket(u16 peer_id, u8 channelnum,
void Connection::RawSend(const BufferedPacket &packet) 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) void Connection::RunTimeouts(float dtime)

View File

@ -97,7 +97,7 @@ void Address::Resolve(const char *name)
freeaddrinfo(resolved); freeaddrinfo(resolved);
} }
std::string Address::serializeString() std::string Address::serializeString() const
{ {
unsigned int a, b, c, d; unsigned int a, b, c, d;
a = (m_address & 0xFF000000)>>24; a = (m_address & 0xFF000000)>>24;

View File

@ -97,7 +97,7 @@ public:
void setPort(unsigned short port); void setPort(unsigned short port);
void print(std::ostream *s) const; void print(std::ostream *s) const;
void print() const; void print() const;
std::string serializeString(); std::string serializeString() const;
private: private:
unsigned int m_address; unsigned int m_address;
unsigned short m_port; unsigned short m_port;