00001 // $Id: CommunicationPolicy.cc 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 "CommunicationPolicy.hh" 00028 //#include "CommunicationPolicy.ih" 00029 00030 // Custom includes 00031 #include <sys/types.h> 00032 #include <sys/socket.h> 00033 #include <errno.h> 00034 #include <senf/Utils/Exception.hh> 00035 00036 //#include "CommunicationPolicy.mpp" 00037 #define prefix_ 00038 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00039 00040 prefix_ void senf::ConnectedCommunicationPolicy::do_listen(FileHandle const & handle, 00041 unsigned backlog) 00042 { 00043 ::listen(handle.fd(),backlog); 00044 } 00045 00046 prefix_ int senf::ConnectedCommunicationPolicy::do_accept(FileHandle const & handle, 00047 struct sockaddr * addr, 00048 unsigned len) 00049 { 00050 int rv = -1; 00051 do { 00052 rv = ::accept(handle.fd(),addr,&len); 00053 if (rv < 0) 00054 switch (errno) { 00055 case EWOULDBLOCK: 00056 return -1; 00057 case EINTR: 00058 break; 00059 default: 00060 SENF_THROW_SYSTEM_EXCEPTION("ConnectedCommunicationPolicy::do_accept failed."); 00061 } 00062 } while (rv<0); 00063 return rv; 00064 } 00065 00066 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00067 #undef prefix_ 00068 //#include "CommunicationPolicy.mpp" 00069 00070 00071 // Local Variables: 00072 // mode: c++ 00073 // fill-column: 100 00074 // c-file-style: "senf" 00075 // indent-tabs-mode: nil 00076 // ispell-local-dictionary: "american" 00077 // compile-command: "scons -u test" 00078 // comment-column: 40 00079 // End: