All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreSocket.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreSocket.h
ipv4, ipv6, unix socket class with SSL support
Qore Programming Language
Copyright 2003 - 2014 David Nichols
will unlink (delete) UNIX domain socket files when closed
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_QORESOCKET_H
#define _QORE_QORESOCKET_H
#include <qore/Qore.h>
#include <sys/types.h>
#include <unistd.h>
#include <strings.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#define QSE_MISC_ERR 0
#define QSE_RECV_ERR -1
#define QSE_NOT_OPEN -2
#define QSE_TIMEOUT -3
#define QSE_SSL_ERR -4
class Queue;
class SocketSource {
friend struct qore_socket_private;
private:
struct qore_socketsource_private *priv; // private implementation
DLLLOCAL SocketSource(const SocketSource&);
DLLLOCAL SocketSource& operator=(const SocketSource&);
public:
DLLEXPORT SocketSource();
DLLEXPORT ~SocketSource();
DLLEXPORT QoreStringNode *takeAddress();
DLLEXPORT QoreStringNode *takeHostName();
DLLEXPORT const char *getAddress() const;
DLLEXPORT const char *getHostName() const;
DLLLOCAL void setAll(QoreObject *o, ExceptionSink *xsink);
};
class QoreSocket {
friend struct qore_socket_private;
private:
struct qore_socket_private *priv;
DLLLOCAL QoreSocket(int n_sock, int n_sfamily, int n_stype, int s_prot, const QoreEncoding *csid);
DLLLOCAL static void convertHeaderToHash(QoreHashNode *h, char *p);
DLLLOCAL QoreSocket(const QoreSocket&);
DLLLOCAL QoreSocket& operator=(const QoreSocket&);
public:
DLLEXPORT QoreSocket();
DLLEXPORT ~QoreSocket();
DLLEXPORT int connect(const char *name, ExceptionSink *xsink = 0);
DLLEXPORT int connect(const char *name, int timeout_ms, ExceptionSink *xsink = 0);
DLLEXPORT int connectINET(const char *host, int prt, ExceptionSink *xsink = 0);
DLLEXPORT int connectINET2(const char *name, const char *service, int family = Q_AF_UNSPEC, int sock_type = Q_SOCK_STREAM, int protocol = 0, int timeout_ms = -1, ExceptionSink *xsink = 0);
DLLEXPORT int connectINET(const char *host, int prt, int timeout_ms, ExceptionSink *xsink = 0);
DLLEXPORT int connectUNIX(const char *p, ExceptionSink *xsink = 0);
DLLEXPORT int connectUNIX(const char *p, int socktype, int protocol = 0, ExceptionSink *xsink = 0);
DLLEXPORT int connectSSL(const char *name, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int connectSSL(const char *name, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int connectINETSSL(const char *host, int prt, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int connectINETSSL(const char *host, int prt, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int connectINET2SSL(const char *name, const char *service, int family, int sock_type, int protocol, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink = 0);
DLLEXPORT int connectUNIXSSL(const char *p, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int connectUNIXSSL(const char *p, int socktype, int protocol, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int bind(const char *name, bool reuseaddr = false);
DLLEXPORT int bind(int prt, bool reuseaddr);
DLLEXPORT int bind(const char *iface, int prt, bool reuseaddr = false);
DLLEXPORT int bind(const struct sockaddr *addr, int addr_size);
DLLEXPORT int bind(int family, const struct sockaddr *addr, int addr_size, int socktype = Q_SOCK_STREAM, int protocol = 0);
DLLEXPORT int bindUNIX(const char *name, ExceptionSink *xsink = 0);
DLLEXPORT int bindUNIX(const char *name, int socktype, int protocol = 0, ExceptionSink *xsink = 0);
DLLEXPORT int bindINET(const char *name, const char *service, bool reuseaddr = true, int family = Q_AF_UNSPEC, int socktype = Q_SOCK_STREAM, int protocol = 0, ExceptionSink *xsink = 0);
DLLEXPORT int getPort();
DLLEXPORT QoreSocket *accept(SocketSource *source, ExceptionSink *xsink);
DLLEXPORT QoreSocket *acceptSSL(SocketSource *source, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int acceptAndReplace(SocketSource *source);
DLLEXPORT QoreSocket *accept(int timeout_ms, ExceptionSink *xsink);
DLLEXPORT QoreSocket *acceptSSL(int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int acceptAndReplace(int timeout_ms, ExceptionSink *xsink);
DLLEXPORT int listen();
DLLEXPORT int listen(int backlog);
DLLEXPORT int send(const char *buf, qore_size_t size);
DLLEXPORT int send(const char *buf, qore_size_t size, ExceptionSink* xsink);
DLLEXPORT int send(const char *buf, qore_size_t size, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int send(const QoreString *msg, ExceptionSink *xsink);
DLLEXPORT int send(const QoreString *msg, int timeout_ms, ExceptionSink *xsink);
DLLEXPORT int send(const BinaryNode *msg);
DLLEXPORT int send(const BinaryNode *msg, ExceptionSink* xsink);
DLLEXPORT int send(const BinaryNode *msg, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int send(int fd, qore_offset_t size = -1);
DLLEXPORT int sendi1(char i);
DLLEXPORT int sendi2(short i);
DLLEXPORT int sendi4(int i);
DLLEXPORT int sendi8(int64 i);
DLLEXPORT int sendi2LSB(short i);
DLLEXPORT int sendi4LSB(int i);
DLLEXPORT int sendi8LSB(int64 i);
DLLEXPORT int sendi1(char i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int sendi2(short i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int sendi4(int i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int sendi8(int64 i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int sendi2LSB(short i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int sendi4LSB(int i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int sendi8LSB(int64 i, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int recvi1(int timeout_ms, char *val);
DLLEXPORT int recvi2(int timeout_ms, short *val);
DLLEXPORT int recvi4(int timeout_ms, int *val);
DLLEXPORT int recvi8(int timeout_ms, int64 *val);
DLLEXPORT int recvi2LSB(int timeout_ms, short *val);
DLLEXPORT int recvi4LSB(int timeout_ms, int *val);
DLLEXPORT int recvi8LSB(int timeout_ms, int64 *val);
DLLEXPORT int recvu1(int timeout_ms, unsigned char *val);
DLLEXPORT int recvu2(int timeout_ms, unsigned short *val);
DLLEXPORT int recvu4(int timeout_ms, unsigned int *val);
DLLEXPORT int recvu2LSB(int timeout_ms, unsigned short *val);
DLLEXPORT int recvu4LSB(int timeout_ms, unsigned int *val);
DLLEXPORT int64 recvi1(int timeout_ms, char *val, ExceptionSink* xsink);
DLLEXPORT int64 recvi2(int timeout_ms, short *val, ExceptionSink* xsink);
DLLEXPORT int64 recvi4(int timeout_ms, int *val, ExceptionSink* xsink);
DLLEXPORT int64 recvi8(int timeout_ms, int64 *val, ExceptionSink* xsink);
DLLEXPORT int64 recvi2LSB(int timeout_ms, short *val, ExceptionSink* xsink);
DLLEXPORT int64 recvi4LSB(int timeout_ms, int *val, ExceptionSink* xsink);
DLLEXPORT int64 recvi8LSB(int timeout_ms, int64 *val, ExceptionSink* xsink);
DLLEXPORT int64 recvu1(int timeout_ms, unsigned char *val, ExceptionSink* xsink);
DLLEXPORT int64 recvu2(int timeout_ms, unsigned short *val, ExceptionSink* xsink);
DLLEXPORT int64 recvu4(int timeout_ms, unsigned int *val, ExceptionSink* xsink);
DLLEXPORT int64 recvu2LSB(int timeout_ms, unsigned short *val, ExceptionSink* xsink);
DLLEXPORT int64 recvu4LSB(int timeout_ms, unsigned int *val, ExceptionSink* xsink);
DLLEXPORT QoreStringNode *recv(qore_offset_t bufsize, int timeout_ms, int *prc);
DLLEXPORT QoreStringNode* recv(qore_offset_t bufsize, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT BinaryNode *recvBinary(qore_offset_t bufsize, int timeout_ms, int *prc);
DLLEXPORT BinaryNode* recvBinary(qore_offset_t bufsize, int timeout_ms, ExceptionSink* xsink);
DLLEXPORT QoreStringNode *recv(int timeout_ms, int *prc);
DLLEXPORT QoreStringNode* recv(int timeout_ms, ExceptionSink* xsink);
DLLEXPORT BinaryNode *recvBinary(int timeout_ms, int *prc);
DLLEXPORT BinaryNode* recvBinary(int timeout_ms, ExceptionSink* xsink);
DLLEXPORT int recv(int fd, qore_offset_t size, int timeout_ms);
DLLEXPORT int sendHTTPMessage(const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
DLLEXPORT int sendHTTPMessage(QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
DLLEXPORT int sendHTTPMessage(ExceptionSink* xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
DLLEXPORT int sendHTTPMessage(ExceptionSink* xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source, int timeout_ms);
DLLEXPORT int sendHTTPResponse(int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source, int timeout_ms);
DLLEXPORT AbstractQoreNode *readHTTPHeader(int timeout_ms, int *prc, int source = QORE_SOURCE_SOCKET);
DLLEXPORT AbstractQoreNode *readHTTPHeader(QoreHashNode *info, int timeout_ms, int *prc, int source = QORE_SOURCE_SOCKET);
DLLEXPORT QoreHashNode *readHTTPHeader(ExceptionSink* xsink, QoreHashNode *info, int timeout_ms, int source = QORE_SOURCE_SOCKET);
DLLEXPORT QoreStringNode* readHTTPHeaderString(ExceptionSink* xsink, int timeout_ms, int source = QORE_SOURCE_SOCKET);
DLLEXPORT QoreHashNode *readHTTPChunkedBodyBinary(int timeout_ms, ExceptionSink *xsink, int source = QORE_SOURCE_SOCKET);
DLLEXPORT QoreHashNode *readHTTPChunkedBody(int timeout_ms, ExceptionSink *xsink, int source = QORE_SOURCE_SOCKET);
DLLEXPORT int setSendTimeout(int ms);
DLLEXPORT int setRecvTimeout(int ms);
DLLEXPORT int getSendTimeout() const;
DLLEXPORT int getRecvTimeout() const;
DLLEXPORT bool isDataAvailable(int timeout_ms = 0) const;
DLLEXPORT bool isDataAvailable(ExceptionSink* xsink, int timeout_ms = 0) const;
DLLEXPORT int close();
DLLEXPORT int shutdown();
DLLEXPORT int shutdownSSL(ExceptionSink *xsink);
DLLEXPORT int getSocket() const;
DLLEXPORT const QoreEncoding *getEncoding() const;
DLLEXPORT void setEncoding(const QoreEncoding *id);
DLLEXPORT bool isOpen() const;
DLLEXPORT const char *getSSLCipherName() const;
DLLEXPORT const char *getSSLCipherVersion() const;
DLLEXPORT bool isSecure() const;
DLLEXPORT long verifyPeerCertificate() const;
DLLEXPORT int upgradeClientToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT int upgradeServerToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink);
DLLEXPORT bool isWriteFinished(int timeout_ms = 0) const;
DLLEXPORT bool isWriteFinished(ExceptionSink* xsink, int timeout_ms = 0) const;
DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink) const;
DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink, bool host_lookup) const;
DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink) const;
DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink, bool host_lookup) const;
DLLEXPORT void clearWarningQueue(ExceptionSink* xsink);
DLLEXPORT void setWarningQueue(ExceptionSink* xsink, int64 warning_ms, int64 warning_bs, class Queue* wq, AbstractQoreNode* arg, int64 min_ms = 1000);
DLLEXPORT QoreHashNode* getUsageInfo() const;
DLLEXPORT void clearStats();
DLLLOCAL static void doException(int rc, const char *meth, int timeout_ms, ExceptionSink *xsink);
DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink);
DLLLOCAL Queue *getQueue();
DLLLOCAL int64 getObjectIDForEvents() const;
DLLLOCAL void cleanup(ExceptionSink *xsink);
DLLLOCAL int setNoDelay(int nodelay);
DLLLOCAL int getNoDelay() const;
DLLLOCAL void setAccept(QoreObject *o);
};
#endif // _QORE_QORESOCKET_H
QoreSocket::isOpen
DLLEXPORT bool isOpen() const
returns true if the socket is open
QoreSocket::getSSLCipherVersion
DLLEXPORT const char * getSSLCipherVersion() const
returns the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none
Q_SOCK_STREAM
#define Q_SOCK_STREAM
platform-independent define for SOCK_STREAM
Definition: common.h:56
QoreSocket::readHTTPHeaderString
DLLEXPORT QoreStringNode * readHTTPHeaderString(ExceptionSink *xsink, int timeout_ms, int source=QORE_SOURCE_SOCKET)
read a HTTP header, caller owns QoreStringNode reference count returned
QoreSocket::isSecure
DLLEXPORT bool isSecure() const
returns true if an SSL connection is active
SocketSource::SocketSource
DLLEXPORT SocketSource()
creates an empty object
QoreEncoding
defines string encoding functions in Qore
Definition: QoreEncoding.h:72
SocketSource
a helper class for getting socket origination information
Definition: QoreSocket.h:61
QoreSocket::acceptAndReplace
DLLEXPORT int acceptAndReplace(SocketSource *source)
accepts a new connection on a listening socket and replaces the current socket with the new connectio...
QoreSocket::sendi8LSB
DLLEXPORT int sendi8LSB(int64 i)
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format th...
QoreSocket::sendi1
DLLEXPORT int sendi1(char i)
sends a 1-byte binary integer data to a connected socket
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:41
QoreSocket::bind
DLLEXPORT int bind(const char *name, bool reuseaddr=false)
binds to a UNIX domain socket or INET interface:port using TCP and returns a status code ...
QoreSocket::getObjectIDForEvents
DLLLOCAL int64 getObjectIDForEvents() const
returns a unique ID for the socket to be used in event messages
QoreSocket::getPeerInfo
DLLEXPORT QoreHashNode * getPeerInfo(ExceptionSink *xsink) const
returns peer information for a connected socket
QoreSocket::getQueue
DLLLOCAL Queue * getQueue()
returns the event queue (not part of the library&#39;s public API)
QoreSocket::verifyPeerCertificate
DLLEXPORT long verifyPeerCertificate() const
returns the peer certificate verification code if an SSL connection is in progress ...
QoreSocket::QoreSocket
DLLEXPORT QoreSocket()
creates an empty, unconnected socket
QoreSocket::readHTTPChunkedBody
DLLEXPORT QoreHashNode * readHTTPChunkedBody(int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET)
receive a string message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count ...
QoreSocket::recvu1
DLLEXPORT int recvu1(int timeout_ms, unsigned char *val)
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an...
QoreSocket::readHTTPHeader
DLLEXPORT AbstractQoreNode * readHTTPHeader(int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET)
read and parse HTTP header, caller owns AbstractQoreNode reference count returned ...
QoreSocket::connectUNIX
DLLEXPORT int connectUNIX(const char *p, ExceptionSink *xsink=0)
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in th...
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 ...
QoreSocket::recvi2
DLLEXPORT int recvi2(int timeout_ms, short *val)
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from t...
SocketSource::getAddress
DLLEXPORT const char * getAddress() const
returns the host address string as a C string
QoreSocket::acceptSSL
DLLEXPORT QoreSocket * acceptSSL(SocketSource *source, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreS...
QoreSocket::cleanup
DLLLOCAL void cleanup(ExceptionSink *xsink)
posts deleted message and removes any event queue
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
QoreSocket::bindUNIX
DLLEXPORT int bindUNIX(const char *name, ExceptionSink *xsink=0)
binds to a UNIX domain socket and returns a status code
QoreSocket::sendi2LSB
DLLEXPORT int sendi2LSB(short i)
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
QoreSocket::readHTTPChunkedBodyBinary
DLLEXPORT QoreHashNode * readHTTPChunkedBodyBinary(int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET)
receive a binary message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count ...
QoreSocket::upgradeClientToSSL
DLLEXPORT int upgradeClientToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
negotiates an SSL connection from the client side
QoreSocket::getEncoding
DLLEXPORT const QoreEncoding * getEncoding() const
returns the character encoding associated with this socket
qore_size_t
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:62
QoreSocket::isDataAvailable
DLLEXPORT bool isDataAvailable(int timeout_ms=0) const
returns true if data is available on the socket in the timeout period in milliseconds ...
qore_offset_t
long qore_offset_t
used for offsets that could be negative
Definition: common.h:65
QoreSocket::shutdown
DLLEXPORT int shutdown()
calls shutdown on the socket
QoreSocket::getSocket
DLLEXPORT int getSocket() const
returns the file descriptor associated with this socket
QoreSocket::bindINET
DLLEXPORT int bindINET(const char *name, const char *service, bool reuseaddr=true, int family=Q_AF_UNSPEC, int socktype=Q_SOCK_STREAM, int protocol=0, ExceptionSink *xsink=0)
binds an INET or INET6 TCP socket to a specific socket address
QoreSocket::recvu2LSB
DLLEXPORT int recvu2LSB(int timeout_ms, unsigned short *val)
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the s...
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
QoreStringNode
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:40
QoreSocket::accept
DLLEXPORT QoreSocket * accept(SocketSource *source, ExceptionSink *xsink)
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connec...
QoreSocket::recv
DLLEXPORT QoreStringNode * recv(qore_offset_t bufsize, int timeout_ms, int *prc)
receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned
SocketSource::getHostName
DLLEXPORT const char * getHostName() const
returns the hostname string as a C string
QoreSocket::~QoreSocket
DLLEXPORT ~QoreSocket()
disconnects if necessary, frees all data, and destroys the socket
QoreSocket::connectINET2SSL
DLLEXPORT int connectINET2SSL(const char *name, const char *service, int family, int sock_type, int protocol, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink=0)
connects to an INET or INET6 socket by hostname and port number or service name and returns a status ...
QoreSocket::setEventQueue
DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink)
sets the event queue (not part of the library&#39;s pubilc API), must be already referenced before call ...
QoreSocket::sendi8
DLLEXPORT int sendi8(int64 i)
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
QoreSocket::recvi4LSB
DLLEXPORT int recvi4LSB(int timeout_ms, int *val)
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the soc...
QoreSocket::recvi2LSB
DLLEXPORT int recvi2LSB(int timeout_ms, short *val)
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the soc...
QoreSocket::recvu4LSB
DLLEXPORT int recvu4LSB(int timeout_ms, unsigned int *val)
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the s...
QoreSocket::connectUNIXSSL
DLLEXPORT int connectUNIXSSL(const char *p, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code...
QoreSocket::sendi4
DLLEXPORT int sendi4(int i)
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
QoreSocket::connectSSL
DLLEXPORT int connectSSL(const char *name, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptio...
QoreSocket::isWriteFinished
DLLEXPORT bool isWriteFinished(int timeout_ms=0) const
returns true if all write data has been written within the timeout period in milliseconds ...
QoreSocket::listen
DLLEXPORT int listen()
sets an open socket to the listening state
QoreSocket::getRecvTimeout
DLLEXPORT int getRecvTimeout() const
get recv timeout in milliseconds
SocketSource::~SocketSource
DLLEXPORT ~SocketSource()
destroys the object and frees all memory
QoreSocket::setEncoding
DLLEXPORT void setEncoding(const QoreEncoding *id)
sets the character encoding for strings sent and received with this socket
SocketSource::takeHostName
DLLEXPORT QoreStringNode * takeHostName()
returns the hostname string field and leaves the object&#39;s hostname field empty; the caller owns the Q...
QoreSocket
provides access to sockets using Qore data structures
Definition: QoreSocket.h:113
QoreObject
the implementation of Qore&#39;s object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:56
QoreSocket::connect
DLLEXPORT int connect(const char *name, ExceptionSink *xsink=0)
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of an...
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
Qore.h
QoreSocket::recvi4
DLLEXPORT int recvi4(int timeout_ms, int *val)
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from t...
QoreSocket::sendHTTPResponse
DLLEXPORT int sendHTTPResponse(int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP response message on the socket
QoreSocket::recvBinary
DLLEXPORT BinaryNode * recvBinary(qore_offset_t bufsize, int timeout_ms, int *prc)
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the refer...
QoreSocket::connectINET2
DLLEXPORT int connectINET2(const char *name, const char *service, int family=Q_AF_UNSPEC, int sock_type=Q_SOCK_STREAM, int protocol=0, int timeout_ms=-1, ExceptionSink *xsink=0)
connects to an INET or INET6 socket by hostname and port number or service name and returns a status ...
QoreSocket::recvu4
DLLEXPORT int recvu4(int timeout_ms, unsigned int *val)
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from...
QoreSocket::shutdownSSL
DLLEXPORT int shutdownSSL(ExceptionSink *xsink)
shuts down an active SSL connection
QoreSocket::connectINETSSL
DLLEXPORT int connectINETSSL(const char *host, int prt, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
connects to an INET socket by hostname and port number, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
QoreSocket::sendi2
DLLEXPORT int sendi2(short i)
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
QoreSocket::connectINET
DLLEXPORT int connectINET(const char *host, int prt, ExceptionSink *xsink=0)
connects to an INET socket by hostname and port number and returns a status code, Qore-language excep...
SocketSource::takeAddress
DLLEXPORT QoreStringNode * takeAddress()
returns the host address string field and leaves the object&#39;s host address field empty; the caller ow...
QoreSocket::recvi8LSB
DLLEXPORT int recvi8LSB(int timeout_ms, int64 *val)
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the so...
QoreSocket::getPort
DLLEXPORT int getPort()
returns the TCP port number, also assigns the interal port number if it must be discovered ...
QoreSocket::getSendTimeout
DLLEXPORT int getSendTimeout() const
get send timeout in milliseconds
QoreSocket::setSendTimeout
DLLEXPORT int setSendTimeout(int ms)
set send timeout in milliseconds
QoreSocket::recvi8
DLLEXPORT int recvi8(int timeout_ms, int64 *val)
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from ...
QoreSocket::send
DLLEXPORT int send(const char *buf, qore_size_t size)
sends binary data on a connected socket
QoreSocket::setRecvTimeout
DLLEXPORT int setRecvTimeout(int ms)
set recv timeout in milliseconds
QoreSocket::close
DLLEXPORT int close()
closes the socket
QoreSocket::recvi1
DLLEXPORT int recvi1(int timeout_ms, char *val)
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an o...
QoreSocket::recvu2
DLLEXPORT int recvu2(int timeout_ms, unsigned short *val)
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from...
Q_AF_UNSPEC
#define Q_AF_UNSPEC
cross-platform define for AF_UNSPEC
Definition: common.h:47
QoreSocket::upgradeServerToSSL
DLLEXPORT int upgradeServerToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
negotiates an SSL connection from the client side
QoreSocket::getSSLCipherName
DLLEXPORT const char * getSSLCipherName() const
returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none
QoreSocket::sendi4LSB
DLLEXPORT int sendi4LSB(int i)
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
QoreSocket::getSocketInfo
DLLEXPORT QoreHashNode * getSocketInfo(ExceptionSink *xsink) const
returns information for the current socket; the socket must be open
QoreSocket::sendHTTPMessage
DLLEXPORT int sendHTTPMessage(const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP request message on the socket
BinaryNode
holds arbitrary binary data
Definition: BinaryNode.h:33