added more meaningful exception text to unix domain sockets
[senf.git] / Socket / Protocols / UN / UNDatagramSocketHandle.cc
index a91f49e..b7221a6 100644 (file)
@@ -1,7 +1,9 @@
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum NETwork research (NET)
-//     David Wagner <david.wagner@fokus.fraunhofer.de>
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     David Wagner <dw6@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
@@ -39,20 +41,19 @@ prefix_ void senf::UNDatagramSocketProtocol::init_client() const
 {
     int sock = ::socket(PF_UNIX,SOCK_DGRAM,0);
     if (sock < 0)
-        throwErrno();
-    body().fd(sock);
+        throw SystemException( "Could not create socket(PF_UNIX,SOCK_DGRAM,0)" );
+    fd(sock);
 }
 
 prefix_ void senf::UNDatagramSocketProtocol::init_client(UNSocketAddress const & address) const 
 {
     init_client();
-    bind(address);
-}
-
-prefix_ std::auto_ptr<senf::SocketProtocol> senf::UNDatagramSocketProtocol::clone()
-    const
-{
-    return std::auto_ptr<SocketProtocol>(new UNDatagramSocketProtocol());
+    try {
+        clientHandle().bind(address);
+    } catch (SystemException & e) {
+        e << "Could not bind to address " << address.path();
+        throw;
+    }
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////