2 * Copyright 2001-2009 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Berkeley Socket-based ListenerService implementation
23 #ifndef __shibsp_socklisten_h__
24 #define __shibsp_socklisten_h__
27 # define FD_SETSIZE 1024
30 #include <shibsp/remoting/ListenerService.h>
32 #include <xercesc/dom/DOM.hpp>
33 #include <xmltooling/logging.h>
34 #include <xmltooling/util/Threads.h>
46 * Berkeley Socket-based ListenerService implementation
48 class SocketListener : public virtual ListenerService
52 SocketListener(const xercesc::DOMElement* e);
55 DDF send(const DDF& in);
56 bool run(bool* shutdown) {
57 return run(true, shutdown);
59 bool run(bool force, bool* shutdown);
61 // Implemented by socket-specific subclasses.
63 typedef SOCKET ShibSocket;
65 typedef int ShibSocket;
67 virtual bool create(ShibSocket& s) const=0;
68 virtual bool connect(ShibSocket& s) const=0;
69 virtual bool bind(ShibSocket& s, bool force=false) const=0;
70 virtual bool accept(ShibSocket& listener, ShibSocket& s) const=0;
71 virtual bool close(ShibSocket& s) const=0;
72 virtual int send(ShibSocket& s, const char* buf, int len) const=0;
73 virtual int recv(ShibSocket& s, char* buf, int buflen) const=0;
77 bool log_error() const; // for OS-level errors
78 xmltooling::logging::Category* log;
82 mutable SocketPool* m_socketpool;
85 // Manage child threads
86 friend class ServerThread;
87 std::map<ShibSocket,xmltooling::Thread*> m_children;
88 xmltooling::Mutex* m_child_lock;
89 xmltooling::CondWait* m_child_wait;
96 #endif /* __shibsp_socklisten_h__ */