4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Definition of non-inline non-template functions
25 #include "BSDSocketProtocol.hh"
26 //#include "BSDSocketProtocol.ih"
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <sys/ioctl.h>
32 #include "SocketHandle.hh"
34 //#include "BSDSocketProtocol.mpp"
36 ///////////////////////////////cc.p////////////////////////////////////////
38 prefix_ std::pair<bool,unsigned> satcom::lib::BSDSocketProtocol::linger()
42 socklen_t len = sizeof(ling);
43 ::memset(&ling,sizeof(ling),0);
44 if (::getsockopt(body().fd(),SOL_SOCKET,SO_LINGER,&ling,&len) < 0)
45 throw SystemException(errno);
46 return std::make_pair(ling.l_onoff, ling.l_linger);
49 prefix_ void satcom::lib::BSDSocketProtocol::linger(bool enable, unsigned timeout)
53 ling.l_onoff = enable;
54 ling.l_linger = timeout;
55 if (::setsockopt(body().fd(),SOL_SOCKET,SO_LINGER,&ling,sizeof(ling)) < 0)
56 throw SystemException(errno);
59 prefix_ struct timeval satcom::lib::BSDSocketProtocol::timestamp()
62 // BUG: Check, why this fails with ENOFILE (!!!!) at least when
63 // called from a tcp socket. Further investigation necessary ...
65 if (::ioctl(body().fd(), SIOCGSTAMP, &tv) < 0)
66 throw SystemException(errno);
70 ///////////////////////////////////////////////////////////////////////////
72 prefix_ bool satcom::lib::AddressableBSDSocketProtocol::reuseaddr()
76 socklen_t len (sizeof(value));
77 if (::getsockopt(body().fd(),SOL_SOCKET,SO_REUSEADDR,&value,&len) < 0)
78 throw SystemException(errno);
82 prefix_ void satcom::lib::AddressableBSDSocketProtocol::reuseaddr(bool value)
86 if (::setsockopt(body().fd(),SOL_SOCKET,SO_REUSEADDR,&ivalue,sizeof(ivalue)) < 0)
87 throw SystemException(errno);
90 ///////////////////////////////cc.e////////////////////////////////////////
92 //#include "BSDSocketProtocol.mpp"
97 // c-file-style: "satcom"