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 <boost/scoped_ptr.hpp>
37 #include <xercesc/dom/DOM.hpp>
38 #include <xmltooling/logging.h>
39 #include <xmltooling/util/Threads.h>
42 # include <winsock2.h>
51 * Berkeley Socket-based ListenerService implementation
53 class SocketListener : public virtual ListenerService
57 SocketListener(const xercesc::DOMElement* e);
60 DDF send(const DDF& in);
62 bool init(bool force);
63 bool run(bool* shutdown);
66 // Implemented by socket-specific subclasses.
68 typedef SOCKET ShibSocket;
70 typedef int ShibSocket;
72 virtual bool create(ShibSocket& s) const=0;
73 virtual bool connect(ShibSocket& s) const=0;
74 virtual bool bind(ShibSocket& s, bool force=false) const=0;
75 virtual bool accept(ShibSocket& listener, ShibSocket& s) const=0;
76 virtual bool close(ShibSocket& s) const=0;
77 virtual int send(ShibSocket& s, const char* buf, int len) const=0;
78 virtual int recv(ShibSocket& s, char* buf, int buflen) const=0;
82 bool log_error(const char* fn=nullptr) const; // for OS-level errors
83 xmltooling::logging::Category* log;
87 boost::scoped_ptr<SocketPool> m_socketpool;
90 // Manage child threads
91 friend class ServerThread;
92 std::map<ShibSocket,xmltooling::Thread*> m_children;
93 boost::scoped_ptr<xmltooling::Mutex> m_child_lock;
94 boost::scoped_ptr<xmltooling::CondWait> m_child_wait;
96 unsigned int m_stackSize;
103 #endif /* __shibsp_socklisten_h__ */