4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.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 #ifndef HH_SocketPolicy_test_
24 #define HH_SocketPolicy_test_ 1
27 #include "SocketPolicy.hh"
28 #include "FileHandle.hh"
30 //#include "SocketPolicy.test.mpp"
31 ///////////////////////////////hh.p////////////////////////////////////////
37 struct SomeAddressingPolicy : public senf::AddressingPolicyBase
39 typedef unsigned Address;
41 static void peer(FileHandle handle, unsigned & addr)
43 static void local(FileHandle, unsigned & addr)
45 static void connect(FileHandle, unsigned addr)
47 static void bind(FileHandle, unsigned addr)
51 struct SomeFramingPolicy : public senf::FramingPolicyBase
54 struct SomeCommunicationPolicy : public senf::CommunicationPolicyBase
56 static int accept(FileHandle handle, unsigned & addr)
57 { addr = 3; return -1; }
58 static int accept(FileHandle handle)
62 struct SomeReadPolicy : public senf::ReadPolicyBase
64 static unsigned const TEST_SIZE = 9;
66 static unsigned read(FileHandle handle, char * buffer, unsigned size)
68 int const n (size<TEST_SIZE?size:TEST_SIZE);
69 ::memcpy(buffer,"TEST-READ",n);
73 static unsigned readfrom(FileHandle handle, char * buffer, unsigned size,
76 return read(handle,buffer,size);
80 struct SomeWritePolicy : public senf::WritePolicyBase
82 static unsigned write(FileHandle handle, char const * buffer, unsigned size)
84 if (size == 10 && ::strncmp(buffer,"TEST-WRITE",10) == 0)
90 static unsigned writeto(FileHandle handle, unsigned address,
91 char const * buffer, unsigned size)
93 return write(handle,buffer,size);
97 struct SomeBufferingPolicy : public senf::BufferingPolicyBase
99 static unsigned rcvbuf(FileHandle handle)
101 static unsigned rcvbuf(FileHandle handle, unsigned size)
104 static unsigned sndbuf(FileHandle handle)
106 static unsigned sndbuf(FileHandle handle, unsigned size)
110 typedef senf::MakeSocketPolicy<
111 SomeAddressingPolicy,
113 SomeCommunicationPolicy,
117 >::policy SomeSocketPolicy;
121 ///////////////////////////////hh.e////////////////////////////////////////
122 //#include "SocketPolicy.test.cci"
123 //#include "SocketPolicy.test.ct"
124 //#include "SocketPolicy.test.cti"
125 //#include "SocketPolicy.test.mpp"
132 // c-file-style: "senf"
133 // indent-tabs-mode: nil
134 // ispell-local-dictionary: "american"
135 // compile-command: "scons -u test"
136 // comment-column: 40