BSDAddressingPolicy.cti

Go to the documentation of this file.
00001 // $Id: BSDAddressingPolicy.cti 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00027 //#include "BSDAddressingPolicy.ih"
00028 
00029 // Custom includes
00030 
00031 #define prefix_ inline
00032 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00033 
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 // senf::BSDAddressingPolicyMixin<Address>
00036 
00037 #ifndef DOXYGEN
00038 template <class Address>
00039 template <class SPolicy>
00040 prefix_ void senf::BSDAddressingPolicyMixin<Address>::
00041 peer(SocketHandle<SPolicy> const & handle, Address & addr,
00042      typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type *)
00043 {
00044     try {
00045         do_peer(handle,addr.sockaddr_p(),addr.socklen_p());
00046     } catch (Exception & e) {
00047         e << "; could not get peer for address \"" << addr << "\"";
00048         throw;
00049     }
00050 }
00051 #else
00052 template <class Address>
00053 template <class SPolicy>
00054 prefix_ void senf::BSDAddressingPolicyMixin<Address>::
00055 peer(SocketHandle<SPolicy> const & handle, Address & addr)
00056 {}
00057 #endif
00058 
00059 #ifndef DOXYGEN
00060 template <class Address>
00061 template <class SPolicy>
00062 prefix_ void senf::BSDAddressingPolicyMixin<Address>::
00063 connect(SocketHandle<SPolicy> const & handle, Address const & addr,
00064         typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type *)
00065 {
00066     try {
00067         do_connect(handle,addr.sockaddr_p(),addr.socklen());
00068     } catch (Exception & e) {
00069         e << "; could not connect to address \"" << addr << "\"";
00070         throw;
00071     }
00072 }
00073 #else
00074 template <class Address>
00075 template <class SPolicy>
00076 prefix_ void senf::BSDAddressingPolicyMixin<Address>::
00077 connect(SocketHandle<SPolicy> const & handle, Address const & addr)
00078 {}
00079 #endif
00080 
00081 template <class Address>
00082 prefix_ void senf::BSDAddressingPolicyMixin<Address>::local(FileHandle const & handle,
00083                                                            Address & addr)
00084 {
00085     try {
00086         do_local(handle,addr.sockaddr_p(),addr.socklen_p());
00087     } catch (Exception & e) {
00088         // TODO: identify socket by some meaningful attribute
00089         e << "; could not get name for address \"" << addr << "\"";
00090         throw;
00091     }
00092 }
00093 
00094 template <class Address>
00095 prefix_ void senf::BSDAddressingPolicyMixin<Address>::bind(FileHandle const & handle,
00096                                                                  Address const & addr)
00097 {
00098     try {
00099         do_bind(handle,addr.sockaddr_p(),addr.socklen());
00100     } catch (Exception & e) {
00101         e << "; could not bind to address \"" << addr << "\"";
00102         throw;
00103     }
00104 }
00105 
00106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00107 #undef prefix_
00108 
00109 
00110 // Local Variables:
00111 // mode: c++
00112 // fill-column: 100
00113 // c-file-style: "senf"
00114 // indent-tabs-mode: nil
00115 // ispell-local-dictionary: "american"
00116 // compile-command: "scons -u ../test"
00117 // comment-column: 40
00118 // End: