Socket/Protocols: Add SO_ERROR getsockopt (BSDSocketProtocol::error())
[senf.git] / Socket / Protocols / GenericAddressingPolicy.cti
index 68f31cd..6cba6c2 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 
 #ifndef DOXYGEN
 template <class Address>
-template <class Policy>
+template <class SPolicy>
 prefix_ void senf::GenericAddressingPolicy<Address>::
-peer(SocketHandle<Policy> handle, Address & addr,
-     typename IfCommunicationPolicyIs<Policy,ConnectedCommunicationPolicy>::type *)
+peer(SocketHandle<SPolicy> handle, Address & addr,
+     typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type *)
 {
     addr.clear();
-    do_peer(handle,addr.sockaddr_p(),addr.sockaddr_len());
+    try {
+        do_peer(handle,addr.sockaddr_p(),addr.sockaddr_len());
+    } catch (Exception & e) {
+        e << "; could not get peer for address \"" << addr << "\"";
+        throw;
+    }
 }
 #else
 template <class Address>
-template <class Policy>
+template <class SPolicy>
 prefix_ void senf::GenericAddressingPolicy<Address>::
-peer(SocketHandle<Policy> handle, Address & addr)
+peer(SocketHandle<SPolicy> handle, Address & addr)
 {}
 #endif
 
 #ifndef DOXYGEN
 template <class Address>
-template <class Policy>
+template <class SPolicy>
 prefix_ void senf::GenericAddressingPolicy<Address>::
-connect(SocketHandle<Policy> handle, Address const & addr,
-        typename IfCommunicationPolicyIs<Policy,ConnectedCommunicationPolicy>::type *)
+connect(SocketHandle<SPolicy> handle, Address const & addr,
+        typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type *)
 {
-    do_connect(handle,addr.sockaddr_p(),addr.sockaddr_len());
+    try {
+        do_connect(handle,addr.sockaddr_p(),addr.sockaddr_len());
+    } catch (Exception & e) {
+        e << "; could not connect to address \"" << addr << "\"";
+        throw;
+    }
 }
 #else
 template <class Address>
-template <class Policy>
+template <class SPolicy>
 prefix_ void senf::GenericAddressingPolicy<Address>::
-connect(SocketHandle<Policy> handle, Address const & addr)
+connect(SocketHandle<SPolicy> handle, Address const & addr)
 {}
 #endif
 
 template <class Address>
 prefix_ void senf::GenericAddressingPolicy<Address>::local(FileHandle handle,
-                                                                  Address & addr)
+                                                           Address & addr)
 {
     addr.clear();
-    do_local(handle,addr.sockaddr_p(),addr.sockaddr_len());
+    try {
+        do_local(handle,addr.sockaddr_p(),addr.sockaddr_len());
+    } catch (Exception & e) {
+        // TODO: identify socket by some meaningful attribute
+        e << "; could not get name for address \"" << addr << "\"";
+        throw;
+    }
 }
 
 template <class Address>
 prefix_ void senf::GenericAddressingPolicy<Address>::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 (Exception & e) {
+        e << "; could not bind to address \"" << addr << "\"";
+        throw;
+    }
 }
 
 ///////////////////////////////cti.e///////////////////////////////////////
@@ -94,6 +115,6 @@ prefix_ void senf::GenericAddressingPolicy<Address>::bind(FileHandle handle,
 // c-file-style: "senf"
 // indent-tabs-mode: nil
 // ispell-local-dictionary: "american"
-// compile-command: "scons -u test"
+// compile-command: "scons -u ../test"
 // comment-column: 40
 // End: