From: jkaeber Date: Tue, 4 Mar 2008 08:30:57 +0000 (+0000) Subject: added address info to socket related SystemExceptions X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=1d9b6ad3acfb5059ecb461286de0dc11a9da9851;p=senf.git added address info to socket related SystemExceptions git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@726 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/Protocols/GenericAddressingPolicy.cti b/Socket/Protocols/GenericAddressingPolicy.cti index 2eaf5c8..7942fe3 100644 --- a/Socket/Protocols/GenericAddressingPolicy.cti +++ b/Socket/Protocols/GenericAddressingPolicy.cti @@ -42,7 +42,12 @@ peer(SocketHandle handle, Address & addr, typename IfCommunicationPolicyIs::type *) { addr.clear(); - do_peer(handle,addr.sockaddr_p(),addr.sockaddr_len()); + try { + do_peer(handle,addr.sockaddr_p(),addr.sockaddr_len()); + } catch (SystemException & e) { + e << "; could not get peer for address \"" << addr << "\""; + throw; + } } #else template @@ -59,7 +64,12 @@ prefix_ void senf::GenericAddressingPolicy
:: connect(SocketHandle handle, Address const & addr, typename IfCommunicationPolicyIs::type *) { - do_connect(handle,addr.sockaddr_p(),addr.sockaddr_len()); + try { + do_connect(handle,addr.sockaddr_p(),addr.sockaddr_len()); + } catch (SystemException & e) { + e << "; could not connect to address \"" << addr << "\""; + throw; + } } #else template @@ -74,14 +84,24 @@ prefix_ void senf::GenericAddressingPolicy
::local(FileHandle handle, Address & addr) { addr.clear(); - do_local(handle,addr.sockaddr_p(),addr.sockaddr_len()); + try { + do_local(handle,addr.sockaddr_p(),addr.sockaddr_len()); + } catch (SystemException & e) { + e << "; could not get name for address \"" << addr << "\""; + throw; + } } template prefix_ void senf::GenericAddressingPolicy
::bind(FileHandle handle, Address const & addr) { - do_bind(handle,addr.sockaddr_p(),addr.sockaddr_len()); + try { + do_bind(handle,addr.sockaddr_p(),addr.sockaddr_len()); + } catch (SystemException & e) { + e << "; could not bind to address \"" << addr << "\""; + throw; + } } ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/Socket/Protocols/Raw/LLAddressing.cci b/Socket/Protocols/Raw/LLAddressing.cci index 1245a10..1054845 100644 --- a/Socket/Protocols/Raw/LLAddressing.cci +++ b/Socket/Protocols/Raw/LLAddressing.cci @@ -114,6 +114,13 @@ prefix_ unsigned senf::LLSocketAddress::sockaddr_len() return sizeof(addr_); } +prefix_ std::ostream & senf::operator<<(std::ostream & os, LLSocketAddress const & llAddr) +{ + // TODO: expose more bytes from sockaddr_ll addr_ + os << "[some LLSocketAddress]"; + return os; +} + ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Socket/Protocols/Raw/LLAddressing.hh b/Socket/Protocols/Raw/LLAddressing.hh index 2a796b5..bd82689 100644 --- a/Socket/Protocols/Raw/LLAddressing.hh +++ b/Socket/Protocols/Raw/LLAddressing.hh @@ -155,6 +155,11 @@ namespace senf { }; /// @} + + /** \brief Write link layer address + \related LLSocketAddress + */ + std::ostream & operator<<(std::ostream & os, LLSocketAddress const & llAddr); } ///////////////////////////////hh.e//////////////////////////////////////// diff --git a/Socket/Protocols/UN/UNAddressing.cc b/Socket/Protocols/UN/UNAddressing.cc index 1e01e51..8eab74b 100644 --- a/Socket/Protocols/UN/UNAddressing.cc +++ b/Socket/Protocols/UN/UNAddressing.cc @@ -83,7 +83,7 @@ prefix_ unsigned senf::UNSocketAddress::sockaddr_len() return sizeof(addr_); } -prefix_ std::ostream & operator<<(std::ostream & os, +prefix_ std::ostream & senf::operator<<(std::ostream & os, senf::UNSocketAddress::UNSocketAddress const & addr) { os << addr.path(); diff --git a/Socket/Protocols/UN/UNDatagramSocketHandle.cc b/Socket/Protocols/UN/UNDatagramSocketHandle.cc index 7586683..d1b66bd 100644 --- a/Socket/Protocols/UN/UNDatagramSocketHandle.cc +++ b/Socket/Protocols/UN/UNDatagramSocketHandle.cc @@ -48,12 +48,7 @@ prefix_ void senf::UNDatagramSocketProtocol::init_client() const prefix_ void senf::UNDatagramSocketProtocol::init_client(UNSocketAddress const & address) const { init_client(); - try { - clientHandle().bind(address); - } catch (SystemException & e) { - e << "; could not bind to address \"" << address.path() << "\""; - throw; - } + clientHandle().bind(address); } ///////////////////////////////cc.e////////////////////////////////////////