Qore Programming Language  0.9.16
QC_Socket.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QC_Socket.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2020 Qore Technologies, s.r.o.
8 
9  provides a thread-safe interface to the QoreSocket object
10 
11  Permission is hereby granted, free of charge, to any person obtaining a
12  copy of this software and associated documentation files (the "Software"),
13  to deal in the Software without restriction, including without limitation
14  the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  and/or sell copies of the Software, and to permit persons to whom the
16  Software is furnished to do so, subject to the following conditions:
17 
18  The above copyright notice and this permission notice shall be included in
19  all copies or substantial portions of the Software.
20 
21  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  DEALINGS IN THE SOFTWARE.
28 
29  Note that the Qore library is released under a choice of three open-source
30  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
31  information.
32 */
33 
34 #ifndef _QORE_CLASS_SOCKET_H
35 
36 #define _QORE_CLASS_SOCKET_H
37 
38 DLLLOCAL QoreClass* initSocketClass(QoreNamespace& qorens);
39 DLLEXPORT extern qore_classid_t CID_SOCKET;
40 DLLEXPORT extern QoreClass* QC_SOCKET;
41 
42 DLLLOCAL TypedHashDecl* init_hashdecl_SocketPollInfo(QoreNamespace& ns);
43 
44 #include <qore/QoreSocket.h>
45 #include <qore/AbstractPrivateData.h>
46 #include <qore/QoreThreadLock.h>
47 #include <qore/QoreSocketObject.h>
48 #include "qore/intern/QC_SSLCertificate.h"
49 #include "qore/intern/QC_SSLPrivateKey.h"
50 
51 class my_socket_priv {
52 public:
53  QoreSocket* socket;
54  QoreSSLCertificate* cert = nullptr;
55  QoreSSLPrivateKey* pk = nullptr;
56  mutable QoreThreadLock m;
57 
58  DLLLOCAL my_socket_priv(QoreSocket* s, QoreSSLCertificate* c = nullptr, QoreSSLPrivateKey* p = nullptr)
59  : socket(s), cert(c), pk(p) {
60  }
61 
62  DLLLOCAL my_socket_priv() : socket(new QoreSocket) {
63  }
64 
65  DLLLOCAL ~my_socket_priv() {
66  if (cert)
67  cert->deref();
68  if (pk)
69  pk->deref();
70 
71  delete socket;
72  }
73 
75  DLLLOCAL void setAccept(QoreObject* o) {
76  socket->setAccept(o);
77  }
78 
79  DLLLOCAL static void setAccept(QoreSocketObject& sock, QoreObject* o) {
80  sock.priv->setAccept(o);
81  }
82 };
83 
84 #endif // _QORE_CLASS_QORESOCKET_H
QoreSocket::setAccept
DLLLOCAL void setAccept(QoreObject *o)
sets backwards-compatible members on accept in a new object - will be removed in a future version of ...
QoreClass
defines a Qore-language class
Definition: QoreClass.h:239
QoreSocket
provides access to sockets using Qore data structures
Definition: QoreSocket.h:126
QoreNamespace
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
QoreSSLCertificate
represents an X509 certificate, reference-counted, dynamically-allocated only
Definition: QoreSSLCertificate.h:42
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:44
QoreObject
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:61
qore_classid_t
unsigned qore_classid_t
used for the unique class ID for QoreClass objects
Definition: common.h:79
AbstractPrivateData::deref
virtual DLLLOCAL void deref(ExceptionSink *xsink)
decrements the reference count of the object
Definition: AbstractPrivateData.h:61
QoreThreadLock
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
QoreSSLPrivateKey
provides access to a private key data structure for SSL connections
Definition: QoreSSLPrivateKey.h:40