4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 #ifndef HH_SENF_Socket_SocketPolicy_test_
30 #define HH_SENF_Socket_SocketPolicy_test_ 1
33 #include "SocketPolicy.hh"
34 #include "FileHandle.hh"
36 //#include "SocketPolicy.test.mpp"
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 struct SomeAddressingPolicy : public senf::AddressingPolicyBase
44 typedef unsigned Address;
46 static void peer(FileHandle handle, unsigned & addr)
48 static void local(FileHandle, unsigned & addr)
50 static void connect(FileHandle, unsigned addr)
52 static void bind(FileHandle, unsigned addr)
56 struct SomeFramingPolicy : public senf::FramingPolicyBase
59 struct SomeCommunicationPolicy : public senf::CommunicationPolicyBase
61 static int accept(FileHandle handle, unsigned & addr)
62 { addr = 3; return -1; }
63 static int accept(FileHandle handle)
67 struct SomeReadPolicy : public senf::ReadPolicyBase
69 static unsigned const TEST_SIZE = 9;
71 static unsigned read(FileHandle handle, char * buffer, unsigned size)
73 int const n (size<TEST_SIZE?size:TEST_SIZE);
74 ::memcpy(buffer,"TEST-READ",n);
78 static unsigned readfrom(FileHandle handle, char * buffer, unsigned size,
81 return read(handle,buffer,size);
85 struct SomeWritePolicy : public senf::WritePolicyBase
87 static unsigned write(FileHandle handle, char const * buffer, unsigned size)
89 if (size == 10 && ::strncmp(buffer,"TEST-WRITE",10) == 0)
95 static unsigned writeto(FileHandle handle, unsigned address,
96 char const * buffer, unsigned size)
98 return write(handle,buffer,size);
102 typedef senf::MakeSocketPolicy<
103 SomeAddressingPolicy,
105 SomeCommunicationPolicy,
108 >::policy SomeSocketPolicy;
112 //-/////////////////////////////////////////////////////////////////////////////////////////////////
113 //#include "SocketPolicy.test.cci"
114 //#include "SocketPolicy.test.ct"
115 //#include "SocketPolicy.test.cti"
116 //#include "SocketPolicy.test.mpp"
123 // c-file-style: "senf"
124 // indent-tabs-mode: nil
125 // ispell-local-dictionary: "american"
126 // compile-command: "scons -u test"
127 // comment-column: 40