2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
24 * Berkeley Socket-based ListenerService implementation.
27 #ifndef __shibsp_socklisten_h__
28 #define __shibsp_socklisten_h__
31 # define FD_SETSIZE 1024
34 #include <shibsp/remoting/ListenerService.h>
36 #include <xercesc/dom/DOM.hpp>
37 #include <xmltooling/logging.h>
38 #include <xmltooling/util/Threads.h>
50 * Berkeley Socket-based ListenerService implementation
52 class SocketListener : public virtual ListenerService
56 SocketListener(const xercesc::DOMElement* e);
59 DDF send(const DDF& in);
61 bool init(bool force);
62 bool run(bool* shutdown);
65 // Implemented by socket-specific subclasses.
67 typedef SOCKET ShibSocket;
69 typedef int ShibSocket;
71 virtual bool create(ShibSocket& s) const=0;
72 virtual bool connect(ShibSocket& s) const=0;
73 virtual bool bind(ShibSocket& s, bool force=false) const=0;
74 virtual bool accept(ShibSocket& listener, ShibSocket& s) const=0;
75 virtual bool close(ShibSocket& s) const=0;
76 virtual int send(ShibSocket& s, const char* buf, int len) const=0;
77 virtual int recv(ShibSocket& s, char* buf, int buflen) const=0;
81 bool log_error(const char* fn=nullptr) const; // for OS-level errors
82 xmltooling::logging::Category* log;
86 mutable SocketPool* m_socketpool;
89 // Manage child threads
90 friend class ServerThread;
91 std::map<ShibSocket,xmltooling::Thread*> m_children;
92 xmltooling::Mutex* m_child_lock;
93 xmltooling::CondWait* m_child_wait;
95 unsigned int m_stackSize;
102 #endif /* __shibsp_socklisten_h__ */