Qore Programming Language 1.19.5
Loading...
Searching...
No Matches
QoreSocket Class Reference

provides access to sockets using Qore data structures More...

#include <QoreSocket.h>

Public Member Methods

DLLEXPORT QoreSocket ()
 creates an empty, unconnected socket
 
DLLEXPORT ~QoreSocket ()
 disconnects if necessary, frees all data, and destroys the socket
 
DLLEXPORT QoreSocketaccept (int timeout_ms, ExceptionSink *xsink)
 accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned More...
 
DLLEXPORT QoreSocketaccept (SocketSource *source, ExceptionSink *xsink)
 accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection More...
 
DLLEXPORT void acceptAllCertificates (bool accept_all=true)
 with peer verification enabled, all certificates are accepted regardless of the validity of the Certificate Authority More...
 
DLLEXPORT int acceptAndReplace (int timeout_ms, ExceptionSink *xsink)
 accepts a new connection on a listening socket and replaces the current socket with the new connection with a timeout; if no connection is accepted within the timeout period, -3 (QSE_TIMEOUT) is returned More...
 
DLLEXPORT int acceptAndReplace (SocketSource *source)
 accepts a new connection on a listening socket and replaces the current socket with the new connection More...
 
DLLEXPORT QoreSocketacceptSSL (int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
 accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned More...
 
DLLEXPORT QoreSocketacceptSSL (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 QoreSocket object for the new connection More...
 
DLLEXPORT int asyncIoWait (int timeout_ms, bool read, bool write) const
 returns 1 if the event was satisfied in the timeout period, 0 if not (= timeout), or -1 in case of an error (see errno in this case) More...
 
DLLEXPORT int bind (const char *iface, int prt, bool reuseaddr=false)
 binds to a TCP INET (ipv4 only) port on the given interface and returns a status code More...
 
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 More...
 
DLLEXPORT int bind (const hashdecl sockaddr *addr, int addr_size)
 binds an INET TCP socket to a specific socket address - do not use, deprecated, use bind(int family, const hashdecl sockaddr *addr, int addr_size, int socktype, int protocol) instead More...
 
DLLEXPORT int bind (int family, const hashdecl sockaddr *addr, int addr_size, int socktype=Q_SOCK_STREAM, int protocol=0)
 binds an INET or INET6 TCP socket to a specific socket address More...
 
DLLEXPORT int bind (int prt, bool reuseaddr)
 binds to a TCP INET (ipv4 only) port on all interfaces and returns a status code More...
 
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=nullptr)
 binds an INET or INET6 TCP socket to a specific socket address More...
 
DLLEXPORT int bindUNIX (const char *name, ExceptionSink *xsink=nullptr)
 binds to a UNIX domain socket and returns a status code More...
 
DLLEXPORT int bindUNIX (const char *name, int socktype, int protocol=0, ExceptionSink *xsink=nullptr)
 binds to a UNIX domain socket and returns a status code More...
 
DLLEXPORT bool captureRemoteCertificates (bool set)
 sets the capture SSL certificate flag More...
 
DLLEXPORT void cleanup (ExceptionSink *xsink)
 posts deleted message and removes any event queue
 
DLLEXPORT int close ()
 closes the socket More...
 
DLLEXPORT int connect (const char *name, ExceptionSink *xsink=nullptr)
 connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT int connect (const char *name, int timeout_ms, ExceptionSink *xsink=nullptr)
 connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT int connectINET (const char *host, int prt, ExceptionSink *xsink=nullptr)
 connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT int connectINET (const char *host, int prt, int timeout_ms, ExceptionSink *xsink=nullptr)
 connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
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=nullptr)
 connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
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=nullptr)
 connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT int connectINETSSL (const char *host, int prt, int timeout_ms, 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 More...
 
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 More...
 
DLLEXPORT int connectSSL (const char *name, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
 connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
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 exceptions are raised in the case of any errors More...
 
DLLEXPORT int connectUNIX (const char *p, ExceptionSink *xsink=nullptr)
 connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT int connectUNIX (const char *p, int socktype, int protocol=0, ExceptionSink *xsink=nullptr)
 connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT int connectUNIXSSL (const char *p, int socktype, int protocol, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
 connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More...
 
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, Qore-language exceptions are raised in the case of any errors More...
 
DLLEXPORT bool getAcceptAllCertificates () const
 returns the current value of the "accept all certificates" flag More...
 
DLLEXPORT int64 getConnectionId () const
 returns a connection ID to help identifying when new connections are made More...
 
DLLEXPORT const QoreEncodinggetEncoding () const
 returns the character encoding associated with this socket More...
 
DLLLOCAL int64 getObjectIDForEvents () const
 returns a unique ID for the socket to be used in event messages
 
DLLEXPORT QoreHashNodegetPeerInfo (ExceptionSink *xsink) const
 returns peer information for a connected socket More...
 
DLLEXPORT QoreHashNodegetPeerInfo (ExceptionSink *xsink, bool host_lookup) const
 returns peer information for a connected socket More...
 
DLLEXPORT int getPort ()
 returns the TCP port number, also assigns the interal port number if it must be discovered
 
DLLLOCAL Queue * getQueue ()
 returns the event queue (not part of the library's public API)
 
DLLEXPORT int getRecvTimeout () const
 get recv timeout in milliseconds
 
DLLEXPORT QoreObjectgetRemoteCertificate () const
 returns a remote certificate if available More...
 
DLLEXPORT int getSendTimeout () const
 get send timeout in milliseconds
 
DLLEXPORT int getSocket () const
 returns the file descriptor associated with this socket More...
 
DLLEXPORT QoreHashNodegetSocketInfo (ExceptionSink *xsink) const
 returns information for the current socket; the socket must be open More...
 
DLLEXPORT QoreHashNodegetSocketInfo (ExceptionSink *xsink, bool host_lookup) const
 returns information for the current socket; the socket must be open More...
 
DLLEXPORT const char * getSSLCipherName () const
 returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none More...
 
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 More...
 
DLLEXPORT int getSslVerifyMode () const
 returns the SSL verification mode More...
 
DLLEXPORT bool isDataAvailable (ExceptionSink *xsink, int timeout_ms=0) const
 returns true if data is available on the socket in the timeout period in milliseconds More...
 
DLLEXPORT bool isDataAvailable (int timeout_ms=0) const
 returns true if data is available on the socket in the timeout period in milliseconds More...
 
DLLEXPORT bool isOpen () const
 returns true if the socket is open More...
 
DLLEXPORT bool isSecure () const
 returns true if an SSL connection is active More...
 
DLLEXPORT bool isWriteFinished (ExceptionSink *xsink, int timeout_ms=0) const
 returns true if all write data has been written within the timeout period in milliseconds More...
 
DLLEXPORT bool isWriteFinished (int timeout_ms=0) const
 returns true if all write data has been written within the timeout period in milliseconds More...
 
DLLEXPORT int listen ()
 sets an open socket to the listening state More...
 
DLLEXPORT int listen (int backlog)
 sets an open socket to the listening state More...
 
DLLEXPORT bool pendingHttpChunkedBody () const
 returns true if a HTTP header was read indicating chunked transfer encoding, but no chunked body has been read
 
DLLEXPORT QoreHashNodereadHTTPChunkedBody (int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET)
 receive a string message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count returned More...
 
DLLEXPORT QoreHashNodereadHTTPChunkedBodyBinary (int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET)
 receive a binary message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count returned More...
 
DLLEXPORT QoreHashNodereadHTTPHeader (ExceptionSink *xsink, QoreHashNode *info, int timeout_ms, int source=QORE_SOURCE_SOCKET)
 read and parse HTTP header, caller owns QoreHashNode reference count returned More...
 
DLLEXPORT AbstractQoreNodereadHTTPHeader (int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET)
 read and parse HTTP header, caller owns AbstractQoreNode reference count returned More...
 
DLLEXPORT AbstractQoreNodereadHTTPHeader (QoreHashNode *info, int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET)
 read and parse HTTP header, caller owns AbstractQoreNode reference count returned More...
 
DLLEXPORT QoreStringNodereadHTTPHeaderString (ExceptionSink *xsink, int timeout_ms, int source=QORE_SOURCE_SOCKET)
 read a HTTP header, caller owns QoreStringNode reference count returned More...
 
DLLEXPORT int recv (int fd, qore_offset_t size, int timeout_ms)
 receive data on the socket and write it to a file descriptor More...
 
DLLEXPORT int recv (int fd, qore_offset_t size, int timeout_ms, ExceptionSink *xsink)
 receive data on the socket and write it to a file descriptor More...
 
DLLEXPORT QoreStringNoderecv (int timeout_ms, ExceptionSink *xsink)
 receive with a timeout value and return a QoreStringNode, caller owns the reference count returned More...
 
DLLEXPORT QoreStringNoderecv (int timeout_ms, int *prc)
 receive with a timeout value and return a QoreStringNode, caller owns the reference count returned More...
 
DLLEXPORT QoreStringNoderecv (qore_offset_t bufsize, int timeout_ms, ExceptionSink *xsink)
 receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned More...
 
DLLEXPORT QoreStringNoderecv (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 More...
 
DLLEXPORT BinaryNoderecvBinary (int timeout_ms, ExceptionSink *xsink)
 receive with a timeout value and return a BinaryNode, caller owns the reference count returned More...
 
DLLEXPORT BinaryNoderecvBinary (int timeout_ms, int *prc)
 receive with a timeout value and return a BinaryNode, caller owns the reference count returned More...
 
DLLEXPORT BinaryNoderecvBinary (qore_offset_t bufsize, int timeout_ms, ExceptionSink *xsink)
 receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the reference count returned More...
 
DLLEXPORT BinaryNoderecvBinary (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 reference count returned More...
 
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 output parameter More...
 
DLLEXPORT int64 recvi1 (int timeout_ms, char *val, ExceptionSink *xsink)
 reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an output parameter More...
 
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 the socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvi2 (int timeout_ms, short *val, ExceptionSink *xsink)
 reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvi2LSB (int timeout_ms, short *val, ExceptionSink *xsink)
 reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 the socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvi4 (int timeout_ms, int *val, ExceptionSink *xsink)
 reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvi4LSB (int timeout_ms, int *val, ExceptionSink *xsink)
 reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 the socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvi8 (int timeout_ms, int64 *val, ExceptionSink *xsink)
 reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvi8LSB (int timeout_ms, int64 *val, ExceptionSink *xsink)
 reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 output parameter More...
 
DLLEXPORT int64 recvu1 (int timeout_ms, unsigned char *val, ExceptionSink *xsink)
 reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an output parameter More...
 
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 the socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvu2 (int timeout_ms, unsigned short *val, ExceptionSink *xsink)
 reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvu2LSB (int timeout_ms, unsigned short *val, ExceptionSink *xsink)
 reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 the socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvu4 (int timeout_ms, unsigned int *val, ExceptionSink *xsink)
 reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More...
 
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 socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int64 recvu4LSB (int timeout_ms, unsigned int *val, ExceptionSink *xsink)
 reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More...
 
DLLEXPORT int send (const BinaryNode *msg)
 sends binary data on a connected socket More...
 
DLLEXPORT int send (const BinaryNode *msg, ExceptionSink *xsink)
 sends binary data on a connected socket More...
 
DLLEXPORT int send (const BinaryNode *msg, int timeout_ms, ExceptionSink *xsink)
 sends binary data on a connected socket More...
 
DLLEXPORT int send (const char *buf, size_t size)
 sends binary data on a connected socket More...
 
DLLEXPORT int send (const char *buf, size_t size, ExceptionSink *xsink)
 sends binary data on a connected socket More...
 
DLLEXPORT int send (const char *buf, size_t size, int timeout_ms, ExceptionSink *xsink)
 sends binary data on a connected socket More...
 
DLLEXPORT int send (const QoreString *msg, ExceptionSink *xsink)
 sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary More...
 
DLLEXPORT int send (const QoreString *msg, int timeout_ms, ExceptionSink *xsink)
 sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary More...
 
DLLEXPORT int send (const QoreStringNode &msg, int timeout_ms, ExceptionSink *xsink)
 sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary More...
 
DLLEXPORT int send (int fd, qore_offset_t size, int timeout_ms, ExceptionSink *xsink)
 sends untranslated data from an open file descriptor More...
 
DLLEXPORT int send (int fd, qore_offset_t size=-1)
 sends untranslated data from an open file descriptor More...
 
DLLEXPORT int sendHTTPMessage (const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
 send an HTTP request message on the socket More...
 
DLLEXPORT int sendHTTPMessage (ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms)
 send an HTTP request message on the socket with a timeout value More...
 
DLLEXPORT int sendHTTPMessage (ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
 send an HTTP request message on the socket More...
 
DLLEXPORT int sendHTTPMessage (QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
 send an HTTP request message on the socket More...
 
DLLEXPORT int sendHTTPMessageWithCallback (ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const ResolvedCallReferenceNode &send_callback, int source, int timeout_ms)
 send an HTTP request message on the socket with a timeout value with a chunked message body using a calback More...
 
DLLEXPORT int sendHTTPResponse (ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms)
 send an HTTP response message on the socket More...
 
DLLEXPORT int sendHTTPResponse (ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
 send an HTTP response message on the socket More...
 
DLLEXPORT int sendHTTPResponse (ExceptionSink *xsink, QoreHashNode *info, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms)
 send an HTTP response message on the socket More...
 
DLLEXPORT int sendHTTPResponse (int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
 send an HTTP response message on the socket More...
 
DLLEXPORT int sendi1 (char i)
 sends a 1-byte binary integer data to a connected socket More...
 
DLLEXPORT int sendi1 (char i, int timeout_ms, ExceptionSink *xsink)
 sends a 1-byte binary integer data to a connected socket More...
 
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 More...
 
DLLEXPORT int sendi2 (short i, int timeout_ms, ExceptionSink *xsink)
 sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More...
 
DLLEXPORT int sendi2LSB (short i)
 sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More...
 
DLLEXPORT int sendi2LSB (short i, int timeout_ms, ExceptionSink *xsink)
 sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More...
 
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 More...
 
DLLEXPORT int sendi4 (int i, int timeout_ms, ExceptionSink *xsink)
 sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More...
 
DLLEXPORT int sendi4LSB (int i)
 sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More...
 
DLLEXPORT int sendi4LSB (int i, int timeout_ms, ExceptionSink *xsink)
 sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More...
 
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 More...
 
DLLEXPORT int sendi8 (int64 i, int timeout_ms, ExceptionSink *xsink)
 sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More...
 
DLLEXPORT int sendi8LSB (int64 i)
 sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More...
 
DLLEXPORT int sendi8LSB (int64 i, int timeout_ms, ExceptionSink *xsink)
 sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More...
 
DLLLOCAL void setAccept (QoreObject *o)
 sets backwards-compatible members on accept in a new object - will be removed in a future version of qore
 
DLLEXPORT void setEncoding (const QoreEncoding *id)
 sets the character encoding for strings sent and received with this socket More...
 
DLLLOCAL void setEventQueue (ExceptionSink *xsink, Queue *q, QoreValue arg, bool with_data)
 sets the event queue (not part of the library's pubilc API), must be already referenced before call
 
DLLEXPORT int setRecvTimeout (int ms)
 set recv timeout in milliseconds
 
DLLEXPORT int setSendTimeout (int ms)
 set send timeout in milliseconds
 
DLLEXPORT void setSslVerifyMode (int mode)
 sets the SSL verification mode More...
 
DLLEXPORT int shutdown ()
 calls shutdown on the socket More...
 
DLLEXPORT int shutdownSSL (ExceptionSink *xsink)
 shuts down an active SSL connection More...
 
DLLEXPORT AbstractPollState * startConnect (ExceptionSink *xsink, const char *name)
 Starts a non-blocking connection to a socket and returns a status code. More...
 
DLLEXPORT AbstractPollState * startRecv (ExceptionSink *xsink, size_t size)
 Starts a non-blocking receive operation on a connected socket. More...
 
DLLEXPORT AbstractPollState * startRecvUntilBytes (ExceptionSink *xsink, const char *pattern, size_t size)
 Starts a non-blocking receive operation on a connected socket. More...
 
DLLEXPORT AbstractPollState * startSend (ExceptionSink *xsink, const char *data, size_t size)
 Starts a non-blocking send operation on a connected socket. More...
 
DLLEXPORT AbstractPollState * startSslConnect (ExceptionSink *xsink, X509 *cert=nullptr, EVP_PKEY *pkey=nullptr)
 Starts a non-blocking upgrade to an SSL connection on a connected client connection. More...
 
DLLEXPORT int upgradeClientToSSL (X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
 negotiates an SSL connection from the client side More...
 
DLLEXPORT int upgradeClientToSSL (X509 *cert, EVP_PKEY *pkey, int timeout_ms, ExceptionSink *xsink)
 negotiates an SSL connection from the client side More...
 
DLLEXPORT int upgradeServerToSSL (X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
 negotiates an SSL connection from the client side More...
 
DLLEXPORT int upgradeServerToSSL (X509 *cert, EVP_PKEY *pkey, int timeout_ms, ExceptionSink *xsink)
 negotiates an SSL connection from the client side More...
 
DLLEXPORT long verifyPeerCertificate () const
 returns the peer certificate verification code if an SSL connection is in progress
 

Friends

class QoreFtpClient
 

Detailed Description

provides access to sockets using Qore data structures

QoreSocket objects also have a QoreEncoding associated with them used for sending and receiving string data. String data received from the socket will be tagged with the appropriate encoding; string data send through the socket will be implicitly converted to the socket's encoding if necessary. This class does no implement any thread locking; thread locking must be performed at a higher level (for example, as with QoreHTTPClient and QoreFtpClient).

Note
currently only supports TCP sockets
See also
QoreEncoding

Member Function Documentation

◆ accept() [1/2]

DLLEXPORT QoreSocket * QoreSocket::accept ( int  timeout_ms,
ExceptionSink xsink 
)

accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned

the socket must be opened and in a listening state before making this call.

Parameters
timeout_msthe timeout in milliseconds; if a timeout occurs then 0 is returned (no Qore-language excepton is raised)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a new QoreSocket object for the new connection (or 0 if an error or timeout occured)
See also

◆ accept() [2/2]

DLLEXPORT QoreSocket * QoreSocket::accept ( SocketSource source,
ExceptionSink xsink 
)

accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection

the socket must be opened and in a listening state before making this call.

Parameters
sourcesource connection information will be written to this object if not 0
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a new QoreSocket object for the new connection (or 0 if an error occured)
See also

◆ acceptAllCertificates()

DLLEXPORT void QoreSocket::acceptAllCertificates ( bool  accept_all = true)

with peer verification enabled, all certificates are accepted regardless of the validity of the Certificate Authority

Parameters
accept_allif true, accepts self-signed certs, if false, then not
Since
Qore 0.8.13

◆ acceptAndReplace() [1/2]

DLLEXPORT int QoreSocket::acceptAndReplace ( int  timeout_ms,
ExceptionSink xsink 
)

accepts a new connection on a listening socket and replaces the current socket with the new connection with a timeout; if no connection is accepted within the timeout period, -3 (QSE_TIMEOUT) is returned

the socket must be opened and in a listening state before making this call.

Parameters
timeout_msthe timeout in milliseconds; if a timeout occurs then 0 is returned (no Qore-language excepton is raised)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 if an error occured, -3 (QSE_TIMEOUT) if a timeout occured
See also

◆ acceptAndReplace() [2/2]

DLLEXPORT int QoreSocket::acceptAndReplace ( SocketSource source)

accepts a new connection on a listening socket and replaces the current socket with the new connection

the socket must be opened and in a listening state before making this call.

Parameters
sourcesource connection information will be written to this object if not 0
Returns
0 for OK, not 0 if an error occured
See also

◆ acceptSSL() [1/2]

DLLEXPORT QoreSocket * QoreSocket::acceptSSL ( int  timeout_ms,
X509 *  cert,
EVP_PKEY *  pkey,
ExceptionSink xsink 
)

accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned

the socket must be opened and in a listening state before making this call.

Parameters
timeout_msthe timeout in milliseconds; if a timeout occurs then 0 is returned (no Qore-language excepton is raised)
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a new QoreSocket object for the new connection (or 0 if an error or timeout occured)
Note
the same as calling QoreSocket::accept() and then QoreSocket::upgradeServerToSSL() on the new socket
See also

◆ acceptSSL() [2/2]

DLLEXPORT QoreSocket * 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 QoreSocket object for the new connection

the socket must be opened and in a listening state before making this call.

Parameters
sourcesource connection information will be written to this object if not 0
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a new QoreSocket object for the new connection (or 0 if an error occured)
Note
the same as calling QoreSocket::accept() and then QoreSocket::upgradeServerToSSL() on the new socket
See also

◆ asyncIoWait()

DLLEXPORT int QoreSocket::asyncIoWait ( int  timeout_ms,
bool  read,
bool  write 
) const

returns 1 if the event was satisfied in the timeout period, 0 if not (= timeout), or -1 in case of an error (see errno in this case)

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
readwait for data to be available for reading from the socket
writewait for data to be written on the socket
See also
Note
This is a low-level socket function, if an SSL connection is in progress, then this function could return 1 for reading due to SSL protocol renegotiation for example. The socket buffer is ignored for this call (unlike isDataAvaialble())
Since
Qore 0.8.12

◆ bind() [1/5]

DLLEXPORT int QoreSocket::bind ( const char *  iface,
int  prt,
bool  reuseaddr = false 
)

binds to a TCP INET (ipv4 only) port on the given interface and returns a status code

Note
the socket will be closed and reopened if necessary
Parameters
ifacethe interface to bind to (hostname or IP address)
prtthe port to bind to
reuseaddrif true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example
Returns
0 for OK, not 0 for error

◆ bind() [2/5]

DLLEXPORT int QoreSocket::bind ( const char *  name,
bool  reuseaddr = false 
)

binds to a UNIX domain socket or INET interface:port using TCP and returns a status code

Note
a socket file will be created on the filesystem if a UNIX domain socket is opened.
the socket will be closed and reopened if necessary
Parameters
nameaddress:port or filename to bind to; if the name has a ':' in it; it's assumed to be an address:port specification for binding to an INET socket, otherwise it is assumed to be a file name for a UNIX domain socket. If there is more than 1 ':' in the name, then the address is assumed to be an ipv6 interface address, otherwise it is assumed to be an ipv4 address.
reuseaddrif true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example
Returns
0 for OK, not 0 for error

◆ bind() [3/5]

DLLEXPORT int QoreSocket::bind ( const hashdecl sockaddr *  addr,
int  addr_size 
)

binds an INET TCP socket to a specific socket address - do not use, deprecated, use bind(int family, const hashdecl sockaddr *addr, int addr_size, int socktype, int protocol) instead

this function will not set the port number; use bind(int family, const hashdecl sockaddr *addr, int addr_size) instead

Note
the socket will be closed and reopened if necessary
Parameters
addrthe socket address to bind to
addr_sizethe size of the addr argument
Returns
0 for OK, not 0 for error
Deprecated:
use bind(int family, const hashdecl sockaddr *addr, int addr_size, int socktype, int protocol) instead

◆ bind() [4/5]

DLLEXPORT int QoreSocket::bind ( int  family,
const hashdecl sockaddr *  addr,
int  addr_size,
int  socktype = Q_SOCK_STREAM,
int  protocol = 0 
)

binds an INET or INET6 TCP socket to a specific socket address

Note
the socket will be closed and reopened if necessary
Parameters
familythe address family (AF_INET or AF_INET6)
addrthe socket address to bind to
addr_sizethe size of the addr argument
socktypethe type of socket (SOCK_STREAM = tcp socket)
protocolthe protocol for the socket
Returns
0 for OK, not 0 for error

◆ bind() [5/5]

DLLEXPORT int QoreSocket::bind ( int  prt,
bool  reuseaddr 
)

binds to a TCP INET (ipv4 only) port on all interfaces and returns a status code

Note
the socket will be closed and reopened if necessary
Parameters
prtthe port to bind to
reuseaddrif true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example
Returns
0 for OK, not 0 for error

◆ bindINET()

DLLEXPORT int QoreSocket::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 = nullptr 
)

binds an INET or INET6 TCP socket to a specific socket address

Note
the socket will be closed and reopened if necessary
Parameters
namethe name or address of the interface, can be 0 meaning all interfaces
servicethe service name or port number
reuseaddrif true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example
familythe address family (AF_INET, AF_INET6, or AF_UNSPEC)
socktypethe type of socket (SOCK_STREAM = tcp socket)
protocolthe protocol for the socket
xsinkif not 0 and an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, not 0 for error

◆ bindUNIX() [1/2]

DLLEXPORT int QoreSocket::bindUNIX ( const char *  name,
ExceptionSink xsink = nullptr 
)

binds to a UNIX domain socket and returns a status code

Note
a socket file will be created on the filesystem if a UNIX domain socket is opened.
the socket will be closed and reopened if necessary
Parameters
nameUNIX filename to bind to
xsinkif not 0 and an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, not 0 for error

◆ bindUNIX() [2/2]

DLLEXPORT int QoreSocket::bindUNIX ( const char *  name,
int  socktype,
int  protocol = 0,
ExceptionSink xsink = nullptr 
)

binds to a UNIX domain socket and returns a status code

Note
a socket file will be created on the filesystem if a UNIX domain socket is opened.
the socket will be closed and reopened if necessary
Parameters
nameUNIX filename to bind to
socktypethe type of socket (SOCK_STREAM = tcp socket)
protocolthe protocol for the socket (use 0 for default)
xsinkif not 0 and an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, not 0 for error

◆ captureRemoteCertificates()

DLLEXPORT bool QoreSocket::captureRemoteCertificates ( bool  set)

sets the capture SSL certificate flag

Parameters
setthe new value of the flag
Returns
the old value of the flag
See also
getRemoteCertificate()
Since
Qore 0.9.3

◆ close()

DLLEXPORT int QoreSocket::close ( )

closes the socket

Deletes the socket file if it was a UNIX domain socket and was created with the QoreSocket::bind() call. Also implicitly calls QoreSocket::shutdownSSL() if an SSL connection is active.

Returns
0 if OK, not 0 on error

◆ connect() [1/2]

DLLEXPORT int QoreSocket::connect ( const char *  name,
ExceptionSink xsink = nullptr 
)

connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors

If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINET() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIX() is called.

Parameters
namethe name of the socket (either hostname:port or file name)
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connectINET()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connect() [2/2]

DLLEXPORT int QoreSocket::connect ( const char *  name,
int  timeout_ms,
ExceptionSink xsink = nullptr 
)

connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors

If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINET() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIX() is called.

Parameters
namethe name of the socket (either hostname:port or file name)
timeout_msthe timeout period in milliseconds
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connectINET()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectINET() [1/2]

DLLEXPORT int QoreSocket::connectINET ( const char *  host,
int  prt,
ExceptionSink xsink = nullptr 
)

connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
hostthe name or IP address of the host
prtthe port number of the remote socket
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connect()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectINET() [2/2]

DLLEXPORT int QoreSocket::connectINET ( const char *  host,
int  prt,
int  timeout_ms,
ExceptionSink xsink = nullptr 
)

connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
hostthe name or IP address of the host
prtthe port number of the remote socket
timeout_msthe timeout period in milliseconds
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connect()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectINET2()

DLLEXPORT int QoreSocket::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 = nullptr 
)

connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
namethe name or address of the host
servicethe port number or service name of the remote socket
familyshould be either AF_INET (for ipv4) or AF_INET6 (for ipv6)
sock_typethe type of socket, normally SOCK_STREAM for tcp sockets or SOCK_DGRAM for udp sockets
protocolthe protocol number, use 0 for the default
timeout_msthe timeout period in milliseconds
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connect()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectINET2SSL()

DLLEXPORT int QoreSocket::connectINET2SSL ( const char *  name,
const char *  service,
int  family,
int  sock_type,
int  protocol,
int  timeout_ms,
X509 *  cert,
EVP_PKEY *  pkey,
ExceptionSink xsink = nullptr 
)

connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
namethe name or address of the host
servicethe port number or service name of the remote socket
familyshould be either AF_INET (for ipv4) or AF_INET6 (for ipv6)
sock_typethe type of socket, normally SOCK_STREAM for tcp sockets or SOCK_DGRAM for udp sockets
protocolthe protocol number, use 0 for the default
timeout_msthe timeout period in milliseconds
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connect()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectINETSSL() [1/2]

DLLEXPORT int QoreSocket::connectINETSSL ( const char *  host,
int  prt,
int  timeout_ms,
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

Parameters
hostthe name or IP address of the host
prtthe port number of the remote socket
timeout_msthe timeout period in milliseconds
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
Note
the same as calling QoreSocket::connectINET() and then QoreSocket::upgradeClientToSSL()
See also
QoreSocket::connect()
QoreSocket::connectUNIX()
QoreSocket::connectINET()
QoreSocket::connectSSL()
QoreSocket::connectUNIXSSL()
QoreSocket::upgradeClientToSSL()

◆ connectINETSSL() [2/2]

DLLEXPORT int QoreSocket::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

Parameters
hostthe name or IP address of the host
prtthe port number of the remote socket
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
Note
the same as calling QoreSocket::connectINET() and then QoreSocket::upgradeClientToSSL()
See also
QoreSocket::connect()
QoreSocket::connectUNIX()
QoreSocket::connectINET()
QoreSocket::connectSSL()
QoreSocket::connectUNIXSSL()
QoreSocket::upgradeClientToSSL()

◆ connectSSL() [1/2]

DLLEXPORT int QoreSocket::connectSSL ( const char *  name,
int  timeout_ms,
X509 *  cert,
EVP_PKEY *  pkey,
ExceptionSink xsink 
)

connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors

If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINETSSL() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIXSSL() is called.

Parameters
namethe name of the socket (either hostname:port or file name)
timeout_msthe timeout period in milliseconds
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
Note
the same as calling QoreSocket::connect() and then QoreSocket::upgradeClientToSSL()
See also
QoreSocket::connect()
QoreSocket::connectINET()
QoreSocket::connectUNIX()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()
QoreSocket::upgradeClientToSSL()

◆ connectSSL() [2/2]

DLLEXPORT int QoreSocket::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 exceptions are raised in the case of any errors

If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINETSSL() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIXSSL() is called.

Parameters
namethe name of the socket (either hostname:port or file name)
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
Note
the same as calling QoreSocket::connect() and then QoreSocket::upgradeClientToSSL()
See also
QoreSocket::connect()
QoreSocket::connectINET()
QoreSocket::connectUNIX()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()
QoreSocket::upgradeClientToSSL()

◆ connectUNIX() [1/2]

DLLEXPORT int QoreSocket::connectUNIX ( const char *  p,
ExceptionSink xsink = nullptr 
)

connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
pthe file name of the UNIX domain socket
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connect()
QoreSocket::connectINET()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectUNIX() [2/2]

DLLEXPORT int QoreSocket::connectUNIX ( const char *  p,
int  socktype,
int  protocol = 0,
ExceptionSink xsink = nullptr 
)

connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
pthe file name of the UNIX domain socket
socktypethe type of socket (SOCK_STREAM = tcp socket)
protocolthe protocol for the socket (use 0 for default)
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
See also
QoreSocket::connect()
QoreSocket::connectINET()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::connectUNIXSSL()

◆ connectUNIXSSL() [1/2]

DLLEXPORT int QoreSocket::connectUNIXSSL ( const char *  p,
int  socktype,
int  protocol,
X509 *  cert,
EVP_PKEY *  pkey,
ExceptionSink xsink 
)

connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors

Parameters
pthe file name of the UNIX domain socket
socktypethe type of socket (SOCK_STREAM = tcp socket)
protocolthe protocol for the socket (use 0 for default)
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
Note
the same as calling QoreSocket::connectUNIX() and then QoreSocket::upgradeClientToSSL()
See also
QoreSocket::connect()
QoreSocket::connectINET()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::upgradeClientToSSL()

◆ connectUNIXSSL() [2/2]

DLLEXPORT int QoreSocket::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, Qore-language exceptions are raised in the case of any errors

Parameters
pthe file name of the UNIX domain socket
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif not 0, if an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, -1 means that an error occured and a Qore-language exception was raised
Note
the same as calling QoreSocket::connectUNIX() and then QoreSocket::upgradeClientToSSL()
See also
QoreSocket::connect()
QoreSocket::connectINET()
QoreSocket::connectUNIX()
QoreSocket::connectSSL()
QoreSocket::connectINETSSL()
QoreSocket::upgradeClientToSSL()

◆ getAcceptAllCertificates()

DLLEXPORT bool QoreSocket::getAcceptAllCertificates ( ) const

returns the current value of the "accept all certificates" flag

Returns
the current value of the "accept all certificates" flag; if true, accepts self-signed certs, if false, then not
Since
Qore 0.8.13

◆ getConnectionId()

DLLEXPORT int64 QoreSocket::getConnectionId ( ) const

returns a connection ID to help identifying when new connections are made

Returns
a connection ID to help identifying when new connections are made
Since
Qore 0.9.3.1

◆ getEncoding()

DLLEXPORT const QoreEncoding * QoreSocket::getEncoding ( ) const

returns the character encoding associated with this socket

Returns
the character encoding associated with this socket

◆ getPeerInfo() [1/2]

DLLEXPORT QoreHashNode * QoreSocket::getPeerInfo ( ExceptionSink xsink) const

returns peer information for a connected socket

if the socket is not connected, a Qore-language exception is thrown

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a hash with the following keys:
  • hostname: the hostname of the remote end (if known or appropriate for the socket type)
  • hostname_desc: a descriptive string for the remote hostname (including the socket type - ie "ipv6[host]")
  • address: the address of the remote end - for UNIX sockets this is the file path
  • address_desc: a descriptive string for the remote address
  • port: the port number if known
  • family: the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)
  • familystr: a string description of the address family ("ipv4", "ipv6", etc)

◆ getPeerInfo() [2/2]

DLLEXPORT QoreHashNode * QoreSocket::getPeerInfo ( ExceptionSink xsink,
bool  host_lookup 
) const

returns peer information for a connected socket

if the socket is not connected, a Qore-language exception is thrown

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
host_lookupdo a host lookup (if this is false the "hostname" and "hostname_desc" are not present in the response hash)
Returns
a hash with the following keys:
  • hostname: the hostname of the remote end (if known or appropriate for the socket type, only performed if host_lookup is true)
  • hostname_desc: a descriptive string for the remote hostname (including the socket type - ie "ipv6[host]", only performed if host_lookup is true)
  • address: the address of the remote end - for UNIX sockets this is the file path
  • address_desc: a descriptive string for the remote address
  • port: the port number if known
  • family: the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)
  • familystr: a string description of the address family ("ipv4", "ipv6", etc)

◆ getRemoteCertificate()

DLLEXPORT QoreObject * QoreSocket::getRemoteCertificate ( ) const

returns a remote certificate if available

Returns
a remote certificate if available or nullptr if not
See also
captureRemoteCertificate()
Since
Qore 0.9.3

◆ getSocket()

DLLEXPORT int QoreSocket::getSocket ( ) const

returns the file descriptor associated with this socket

Returns
the file descriptor associated with this socket

◆ getSocketInfo() [1/2]

DLLEXPORT QoreHashNode * QoreSocket::getSocketInfo ( ExceptionSink xsink) const

returns information for the current socket; the socket must be open

if the socket is not open, a Qore-language exception is thrown

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a hash with the following keys:
  • hostname: the hostname of the remote end (if known or appropriate for the socket type, only performed if host_lookup is true)
  • hostname_desc: a descriptive string for the remote hostname (including the socket type - ie "ipv6[host]", only performed if host_lookup is true)
  • address: the address of the local interface - for UNIX sockets this is the file path
  • address_desc: a descriptive string for the local interface
  • port: the port number if known
  • family: the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)
  • familystr: a string description of the address family ("ipv4", "ipv6", etc)

◆ getSocketInfo() [2/2]

DLLEXPORT QoreHashNode * QoreSocket::getSocketInfo ( ExceptionSink xsink,
bool  host_lookup 
) const

returns information for the current socket; the socket must be open

if the socket is not open, a Qore-language exception is thrown

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
host_lookupdo a host lookup (if this is false the "hostname" and "hostname_desc" are not present in the response hash)
Returns
a hash with the following keys:
  • hostname: the hostname for the local interface (if known or appropriate for the socket type)
  • hostname_desc: a descriptive string for the local hostname (including the socket type - ie "ipv6[host]")
  • address: the address of the local interface - for UNIX sockets this is the file path
  • address_desc: a descriptive string for the local interface
  • port: the port number if known
  • family: the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)
  • familystr: a string description of the address family ("ipv4", "ipv6", etc)

◆ getSSLCipherName()

DLLEXPORT const char * QoreSocket::getSSLCipherName ( ) const

returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none

Returns
the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none

◆ getSSLCipherVersion()

DLLEXPORT const char * QoreSocket::getSSLCipherVersion ( ) const

returns the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none

Returns
the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none

◆ getSslVerifyMode()

DLLEXPORT int QoreSocket::getSslVerifyMode ( ) const

returns the SSL verification mode

Returns
see the mode parameter of SSL_set_verify() for details
Since
Qore 0.8.13

◆ isDataAvailable() [1/2]

DLLEXPORT bool QoreSocket::isDataAvailable ( ExceptionSink xsink,
int  timeout_ms = 0 
) const

returns true if data is available on the socket in the timeout period in milliseconds

The socket must be connected before this call is made. use a timeout of 0 to see if there is any data available on the socket

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
Returns
true if data is available within the timeout period
See also
asyncIoWait()
Note
if data is available in the socket buffer, this call returns immediately
Since
Qore 0.8.8

◆ isDataAvailable() [2/2]

DLLEXPORT bool QoreSocket::isDataAvailable ( int  timeout_ms = 0) const

returns true if data is available on the socket in the timeout period in milliseconds

The socket must be connected before this call is made. use a timeout of 0 to see if there is any data available on the socket

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
Returns
true if data is available within the timeout period
See also
asyncIoWait()
Note
if data is available in the socket buffer, this call returns immediately

◆ isOpen()

DLLEXPORT bool QoreSocket::isOpen ( ) const

returns true if the socket is open

Returns
true if the socket is open

◆ isSecure()

DLLEXPORT bool QoreSocket::isSecure ( ) const

returns true if an SSL connection is active

Returns
true if an SSL connection is active

◆ isWriteFinished() [1/2]

DLLEXPORT bool QoreSocket::isWriteFinished ( ExceptionSink xsink,
int  timeout_ms = 0 
) const

returns true if all write data has been written within the timeout period in milliseconds

The socket must be connected before this call is made. use a timeout of 0 to receive an answer immediately

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
Returns
true if data is available within the timeout period
Since
Qore 0.8.8

◆ isWriteFinished() [2/2]

DLLEXPORT bool QoreSocket::isWriteFinished ( int  timeout_ms = 0) const

returns true if all write data has been written within the timeout period in milliseconds

The socket must be connected before this call is made. use a timeout of 0 to receive an answer immediately

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
Returns
true if data is available within the timeout period
See also
asyncIoWait()

◆ listen() [1/2]

DLLEXPORT int QoreSocket::listen ( )

sets an open socket to the listening state

Returns
0 for OK, not 0 if an error occured

◆ listen() [2/2]

DLLEXPORT int QoreSocket::listen ( int  backlog)

sets an open socket to the listening state

Parameters
backlogthe size of the queue for pending connections
Returns
0 for OK, not 0 if an error occured
Since
Qore 0.8.8

◆ readHTTPChunkedBody()

DLLEXPORT QoreHashNode * QoreSocket::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 returned

The socket must be connected before this call is made. The message body is returned as a QoreStringNode in the "body" key, any footers read after the body are returned as the other hash keys in the hash.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
sourcethe event source code for socket events
Returns
the message body as the value of the "body" key and any footers read after the body as other keys (0 if an error occurs)
See also
QoreStringNode

◆ readHTTPChunkedBodyBinary()

DLLEXPORT QoreHashNode * QoreSocket::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 returned

The socket must be connected before this call is made. The message body is returned as a BinaryNode in the "body" key, any footers read after the body are returned as the other hash keys in the hash.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
sourcethe event source code for socket events
Returns
the message body as the value of the "body" key and any footers read after the body as other keys (0 if an error occurs)
See also
BinaryNode

◆ readHTTPHeader() [1/3]

DLLEXPORT QoreHashNode * QoreSocket::readHTTPHeader ( ExceptionSink xsink,
QoreHashNode info,
int  timeout_ms,
int  source = QORE_SOURCE_SOCKET 
)

read and parse HTTP header, caller owns QoreHashNode reference count returned

The socket must be connected before this call is made.

Note
does not read the message body; message body must be read manually
Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
infothe request-uri or response-uri is written to this hash if non-null; neither of these keys should be present in the hash before the call
timeout_msin milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
sourcethe event source code for socket events
Returns
if 0, an exception was raised, if not 0, caller owns the reference count returned

◆ readHTTPHeader() [2/3]

DLLEXPORT AbstractQoreNode * QoreSocket::readHTTPHeader ( int  timeout_ms,
int *  prc,
int  source = QORE_SOURCE_SOCKET 
)

read and parse HTTP header, caller owns AbstractQoreNode reference count returned

The socket must be connected before this call is made.

Note
does not read the message body; message body must be read manually
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
prcoutput parameter: 0 or -2: remote end closed the connection, -1: receive error, -3: timeout
sourcethe event source code for socket events
Returns
if 0 (and prc == 0), the socket was closed on the remote end without a response, if the type is NT_STRING, the response could not be parsed, if not 0, caller owns the reference count returned

◆ readHTTPHeader() [3/3]

DLLEXPORT AbstractQoreNode * QoreSocket::readHTTPHeader ( QoreHashNode info,
int  timeout_ms,
int *  prc,
int  source = QORE_SOURCE_SOCKET 
)

read and parse HTTP header, caller owns AbstractQoreNode reference count returned

The socket must be connected before this call is made.

Note
does not read the message body; message body must be read manually
Parameters
infothe request-uri or response-uri is written to this hash if non-null; neither of these keys should be present in the hash before the call
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
prcoutput parameter: 0 or -2: remote end closed the connection, -1: receive error, -3: timeout
sourcethe event source code for socket events
Returns
if 0 (and prc == 0), the socket was closed on the remote end without a response, if the type is NT_STRING, the response could not be parsed, if not 0, caller owns the reference count returned

◆ readHTTPHeaderString()

DLLEXPORT QoreStringNode * QoreSocket::readHTTPHeaderString ( ExceptionSink xsink,
int  timeout_ms,
int  source = QORE_SOURCE_SOCKET 
)

read a HTTP header, caller owns QoreStringNode reference count returned

The socket must be connected before this call is made.

Note
does not read the message body; message body must be read manually
Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
timeout_msin milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
sourcethe event source code for socket events
Returns
if 0, an exception was raised, if not 0, caller owns the reference count returned

◆ recv() [1/6]

DLLEXPORT int QoreSocket::recv ( int  fd,
qore_offset_t  size,
int  timeout_ms 
)

receive data on the socket and write it to a file descriptor

The socket must be connected before this call is made.

Parameters
fdthe file descriptor to write to, must be already opened for writing
sizethe number of bytes to read from the socket, -1 to read until the socket is closed
timeout_mstimeout for socket I/O in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
Returns
0 for OK, not 0 for error
Note
the timeout value applies to each read from the socket

◆ recv() [2/6]

DLLEXPORT int QoreSocket::recv ( int  fd,
qore_offset_t  size,
int  timeout_ms,
ExceptionSink xsink 
)

receive data on the socket and write it to a file descriptor

The socket must be connected before this call is made.

Parameters
fdthe file descriptor to write to, must be already opened for writing
sizethe number of bytes to read from the socket, -1 to read until the socket is closed
timeout_mstimeout for socket I/O in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 for OK, not 0 for error
Note
the timeout value applies to each read from the socket
Since
Qore 0.8.12.3

◆ recv() [3/6]

DLLEXPORT QoreStringNode * QoreSocket::recv ( int  timeout_ms,
ExceptionSink xsink 
)

receive with a timeout value and return a QoreStringNode, caller owns the reference count returned

The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a QoreStringNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the data read as a QoreStringNode tagged with the socket's QoreEncoding, caller owns the reference count returned (0 if an error occurs)
See also
QoreEncoding

◆ recv() [4/6]

DLLEXPORT QoreStringNode * QoreSocket::recv ( int  timeout_ms,
int *  prc 
)

receive with a timeout value and return a QoreStringNode, caller owns the reference count returned

The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a QoreStringNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
prcoutput parameter: 0 for OK, not 0 for error
Returns
the data read as a QoreStringNode tagged with the socket's QoreEncoding, caller owns the reference count returned (0 if an error occurs)
See also
QoreEncoding

◆ recv() [5/6]

DLLEXPORT QoreStringNode * QoreSocket::recv ( qore_offset_t  bufsize,
int  timeout_ms,
ExceptionSink xsink 
)

receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned

The socket must be connected before this call is made.

Parameters
bufsizenumber of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side
timeout_msin milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the data read as a QoreStringNode tagged with the socket's QoreEncoding, caller owns the reference count returned (0 if an error occurs)
See also
QoreEncoding

◆ recv() [6/6]

DLLEXPORT QoreStringNode * QoreSocket::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

The socket must be connected before this call is made.

Parameters
bufsizenumber of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
prcoutput parameter: 0 for OK, not 0 for error
Returns
the data read as a QoreStringNode tagged with the socket's QoreEncoding, caller owns the reference count returned (0 if an error occurs)
See also
QoreEncoding

◆ recvBinary() [1/4]

DLLEXPORT BinaryNode * QoreSocket::recvBinary ( int  timeout_ms,
ExceptionSink xsink 
)

receive with a timeout value and return a BinaryNode, caller owns the reference count returned

The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a BinaryNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the data read as a BinaryNode, caller owns the reference count returned (0 if an error occurs)

◆ recvBinary() [2/4]

DLLEXPORT BinaryNode * QoreSocket::recvBinary ( int  timeout_ms,
int *  prc 
)

receive with a timeout value and return a BinaryNode, caller owns the reference count returned

The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a BinaryNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
prcoutput parameter: 0 for OK, not 0 for error
Returns
the data read as a BinaryNode, caller owns the reference count returned (0 if an error occurs)

◆ recvBinary() [3/4]

DLLEXPORT BinaryNode * QoreSocket::recvBinary ( qore_offset_t  bufsize,
int  timeout_ms,
ExceptionSink xsink 
)

receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the reference count returned

The socket must be connected before this call is made.

Parameters
bufsizenumber of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the data read as a BinaryNode, caller owns the reference count returned (0 if an error occurs)

◆ recvBinary() [4/4]

DLLEXPORT BinaryNode * QoreSocket::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 reference count returned

The socket must be connected before this call is made.

Parameters
bufsizenumber of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
prcoutput parameter: 0 for OK, not 0 for error
Returns
the data read as a BinaryNode, caller owns the reference count returned (0 if an error occurs)

◆ recvi1() [1/2]

DLLEXPORT int QoreSocket::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 output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvu1()

◆ recvi1() [2/2]

DLLEXPORT int64 QoreSocket::recvi1 ( int  timeout_ms,
char *  val,
ExceptionSink xsink 
)

reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvu1()

◆ recvi2() [1/2]

DLLEXPORT int QoreSocket::recvi2 ( int  timeout_ms,
short *  val 
)

reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi2LSB()
QoreSocket::recvu2()
QoreSocket::recvu2LSB()

◆ recvi2() [2/2]

DLLEXPORT int64 QoreSocket::recvi2 ( int  timeout_ms,
short *  val,
ExceptionSink xsink 
)

reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi2LSB()
QoreSocket::recvu2()
QoreSocket::recvu2LSB()

◆ recvi2LSB() [1/2]

DLLEXPORT int QoreSocket::recvi2LSB ( int  timeout_ms,
short *  val 
)

reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvi2() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi2()
QoreSocket::recvu2()
QoreSocket::recvu2LSB()

◆ recvi2LSB() [2/2]

DLLEXPORT int64 QoreSocket::recvi2LSB ( int  timeout_ms,
short *  val,
ExceptionSink xsink 
)

reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvi2() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi2()
QoreSocket::recvu2()
QoreSocket::recvu2LSB()

◆ recvi4() [1/2]

DLLEXPORT int QoreSocket::recvi4 ( int  timeout_ms,
int *  val 
)

reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi4LSB()
QoreSocket::recvu4()
QoreSocket::recvu4LSB()

◆ recvi4() [2/2]

DLLEXPORT int64 QoreSocket::recvi4 ( int  timeout_ms,
int *  val,
ExceptionSink xsink 
)

reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi4LSB()
QoreSocket::recvu4()
QoreSocket::recvu4LSB()

◆ recvi4LSB() [1/2]

DLLEXPORT int QoreSocket::recvi4LSB ( int  timeout_ms,
int *  val 
)

reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvi4() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi4()
QoreSocket::recvu4()
QoreSocket::recvu4LSB()

◆ recvi4LSB() [2/2]

DLLEXPORT int64 QoreSocket::recvi4LSB ( int  timeout_ms,
int *  val,
ExceptionSink xsink 
)

reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvi4() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi4()
QoreSocket::recvu4()
QoreSocket::recvu4LSB()

◆ recvi8() [1/2]

DLLEXPORT int QoreSocket::recvi8 ( int  timeout_ms,
int64 val 
)

reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi8LSB()
QoreSocket::recvu8()
QoreSocket::recvu8LSB()

◆ recvi8() [2/2]

DLLEXPORT int64 QoreSocket::recvi8 ( int  timeout_ms,
int64 val,
ExceptionSink xsink 
)

reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi8LSB()
QoreSocket::recvu8()
QoreSocket::recvu8LSB()

◆ recvi8LSB() [1/2]

DLLEXPORT int QoreSocket::recvi8LSB ( int  timeout_ms,
int64 val 
)

reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvi8() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi8()

◆ recvi8LSB() [2/2]

DLLEXPORT int64 QoreSocket::recvi8LSB ( int  timeout_ms,
int64 val,
ExceptionSink xsink 
)

reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvi8() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi8()

◆ recvu1() [1/2]

DLLEXPORT int QoreSocket::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 output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi1()

◆ recvu1() [2/2]

DLLEXPORT int64 QoreSocket::recvu1 ( int  timeout_ms,
unsigned char *  val,
ExceptionSink xsink 
)

reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi1()

◆ recvu2() [1/2]

DLLEXPORT int QoreSocket::recvu2 ( int  timeout_ms,
unsigned short *  val 
)

reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi2()
QoreSocket::recvu2LSB()
QoreSocket::recvi2LSB()

◆ recvu2() [2/2]

DLLEXPORT int64 QoreSocket::recvu2 ( int  timeout_ms,
unsigned short *  val,
ExceptionSink xsink 
)

reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi2()
QoreSocket::recvu2LSB()
QoreSocket::recvi2LSB()

◆ recvu2LSB() [1/2]

DLLEXPORT int QoreSocket::recvu2LSB ( int  timeout_ms,
unsigned short *  val 
)

reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvu2() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvu2()
QoreSocket::recvi2()
QoreSocket::recvi2LSB()

◆ recvu2LSB() [2/2]

DLLEXPORT int64 QoreSocket::recvu2LSB ( int  timeout_ms,
unsigned short *  val,
ExceptionSink xsink 
)

reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvu2() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvu2()
QoreSocket::recvi2()
QoreSocket::recvi2LSB()

◆ recvu4() [1/2]

DLLEXPORT int QoreSocket::recvu4 ( int  timeout_ms,
unsigned int *  val 
)

reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvi4()
QoreSocket::recvu4LSB()
QoreSocket::recvi4LSB()

◆ recvu4() [2/2]

DLLEXPORT int64 QoreSocket::recvu4 ( int  timeout_ms,
unsigned int *  val,
ExceptionSink xsink 
)

reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvi4()
QoreSocket::recvu4LSB()
QoreSocket::recvi4LSB()

◆ recvu4LSB() [1/2]

DLLEXPORT int QoreSocket::recvu4LSB ( int  timeout_ms,
unsigned int *  val 
)

reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvu4() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
Returns
0 for OK, not 0 for error
See also
QoreSocket::recvu4()
QoreSocket::recvi4()
QoreSocket::recvi4LSB()

◆ recvu4LSB() [2/2]

DLLEXPORT int64 QoreSocket::recvu4LSB ( int  timeout_ms,
unsigned int *  val,
ExceptionSink xsink 
)

reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::recvu4() should be used instead
Parameters
timeout_mstimeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting
valoutput parameter: the integer value read from the file
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
<= 0 = error, otherwise the number of bytes received
See also
QoreSocket::recvu4()
QoreSocket::recvi4()
QoreSocket::recvi4LSB()

◆ send() [1/11]

DLLEXPORT int QoreSocket::send ( const BinaryNode msg)

sends binary data on a connected socket

Parameters
msgthe data to send
Returns
0 for OK, not 0 if an error occured

◆ send() [2/11]

DLLEXPORT int QoreSocket::send ( const BinaryNode msg,
ExceptionSink xsink 
)

sends binary data on a connected socket

Parameters
msgthe data to send
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ send() [3/11]

DLLEXPORT int QoreSocket::send ( const BinaryNode msg,
int  timeout_ms,
ExceptionSink xsink 
)

sends binary data on a connected socket

Parameters
msgthe data to send
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ send() [4/11]

DLLEXPORT int QoreSocket::send ( const char *  buf,
size_t  size 
)

sends binary data on a connected socket

Parameters
bufthe data to send
sizethe size of the data to send
Returns
0 for OK, not 0 if an error occured

◆ send() [5/11]

DLLEXPORT int QoreSocket::send ( const char *  buf,
size_t  size,
ExceptionSink xsink 
)

sends binary data on a connected socket

Parameters
bufthe data to send
sizethe size of the data to send
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ send() [6/11]

DLLEXPORT int QoreSocket::send ( const char *  buf,
size_t  size,
int  timeout_ms,
ExceptionSink xsink 
)

sends binary data on a connected socket

Parameters
bufthe data to send
sizethe size of the data to send
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ send() [7/11]

DLLEXPORT int QoreSocket::send ( const QoreString msg,
ExceptionSink xsink 
)

sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary

Parameters
msgthe string to send (must not be 0)
xsinkif an error occurs in converting the string's character encoding or in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ send() [8/11]

DLLEXPORT int QoreSocket::send ( const QoreString msg,
int  timeout_ms,
ExceptionSink xsink 
)

sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary

Parameters
msgthe string to send (must not be 0)
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in converting the string's character encoding or in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ send() [9/11]

DLLEXPORT int QoreSocket::send ( const QoreStringNode msg,
int  timeout_ms,
ExceptionSink xsink 
)

sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary

Parameters
msgthe string to send (must not be 0)
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in converting the string's character encoding or in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
Since
Qore 0.9.4

◆ send() [10/11]

DLLEXPORT int QoreSocket::send ( int  fd,
qore_offset_t  size,
int  timeout_ms,
ExceptionSink xsink 
)

sends untranslated data from an open file descriptor

Parameters
fda file descriptor, open for reading
sizethe number of bytes to send (-1 = send all until EOF)
timeout_msa timeout in milliseconds for socket I/O operations
xsinkif an I/O error occurs, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
Since
Qore 0.8.12.3

◆ send() [11/11]

DLLEXPORT int QoreSocket::send ( int  fd,
qore_offset_t  size = -1 
)

sends untranslated data from an open file descriptor

Parameters
fda file descriptor, open for reading
sizethe number of bytes to send (-1 = send all until EOF)
Returns
0 for OK, not 0 if an error occured

◆ sendHTTPMessage() [1/4]

DLLEXPORT int QoreSocket::sendHTTPMessage ( const char *  method,
const char *  path,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source = QORE_SOURCE_SOCKET 
)

send an HTTP request message on the socket

The socket must be connected before this call is made.

Parameters
methodthe method string to use in the header - no validity checking is made on this string
paththe path string to use in the header, if the path is empty then '/' is sent
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
Returns
0 for OK, not 0 for error

◆ sendHTTPMessage() [2/4]

DLLEXPORT int QoreSocket::sendHTTPMessage ( ExceptionSink xsink,
QoreHashNode info,
const char *  method,
const char *  path,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source,
int  timeout_ms 
)

send an HTTP request message on the socket with a timeout value

The socket must be connected before this call is made.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
infoif not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call
methodthe method string to use in the header - no validity checking is made on this string
paththe path string to use in the header, if the path is empty then '/' is sent
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
Returns
0 for OK, not 0 for error

◆ sendHTTPMessage() [3/4]

DLLEXPORT int QoreSocket::sendHTTPMessage ( ExceptionSink xsink,
QoreHashNode info,
const char *  method,
const char *  path,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source = QORE_SOURCE_SOCKET 
)

send an HTTP request message on the socket

The socket must be connected before this call is made.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
infoif not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call
methodthe method string to use in the header - no validity checking is made on this string
paththe path string to use in the header, if the path is empty then '/' is sent
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
Returns
0 for OK, not 0 for error

◆ sendHTTPMessage() [4/4]

DLLEXPORT int QoreSocket::sendHTTPMessage ( QoreHashNode info,
const char *  method,
const char *  path,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source = QORE_SOURCE_SOCKET 
)

send an HTTP request message on the socket

The socket must be connected before this call is made.

Parameters
infoif not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call
methodthe method string to use in the header - no validity checking is made on this string
paththe path string to use in the header, if the path is empty then '/' is sent
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
Returns
0 for OK, not 0 for error

◆ sendHTTPMessageWithCallback()

DLLEXPORT int QoreSocket::sendHTTPMessageWithCallback ( ExceptionSink xsink,
QoreHashNode info,
const char *  method,
const char *  path,
const char *  http_version,
const QoreHashNode headers,
const ResolvedCallReferenceNode send_callback,
int  source,
int  timeout_ms 
)

send an HTTP request message on the socket with a timeout value with a chunked message body using a calback

The socket must be connected before this call is made.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
infoif not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call
methodthe method string to use in the header - no validity checking is made on this string
paththe path string to use in the header, if the path is empty then '/' is sent
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
send_callbackthe callback for the chunked message body
sourcethe event source code for socket events
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
Returns
0 for OK, not 0 for error

◆ sendHTTPResponse() [1/4]

DLLEXPORT int QoreSocket::sendHTTPResponse ( ExceptionSink xsink,
int  code,
const char *  desc,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source,
int  timeout_ms 
)

send an HTTP response message on the socket

The socket must be connected before this call is made.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
codethe HTTP response code
descthe text description for the response code
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
Returns
0 for OK, not 0 for error

◆ sendHTTPResponse() [2/4]

DLLEXPORT int QoreSocket::sendHTTPResponse ( ExceptionSink xsink,
int  code,
const char *  desc,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source = QORE_SOURCE_SOCKET 
)

send an HTTP response message on the socket

The socket must be connected before this call is made.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
codethe HTTP response code
descthe text description for the response code
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
Returns
0 for OK, not 0 for error

◆ sendHTTPResponse() [3/4]

DLLEXPORT int QoreSocket::sendHTTPResponse ( ExceptionSink xsink,
QoreHashNode info,
int  code,
const char *  desc,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source,
int  timeout_ms 
)

send an HTTP response message on the socket

The socket must be connected before this call is made.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
infoif not null, the response-uri will be written to this hash, neither of these keys should be set before this call
codethe HTTP response code
descthe text description for the response code
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
Returns
0 for OK, not 0 for error
Since
Qore 0.9.4

◆ sendHTTPResponse() [4/4]

DLLEXPORT int QoreSocket::sendHTTPResponse ( int  code,
const char *  desc,
const char *  http_version,
const QoreHashNode headers,
const void *  data,
size_t  size,
int  source = QORE_SOURCE_SOCKET 
)

send an HTTP response message on the socket

The socket must be connected before this call is made.

Parameters
codethe HTTP response code
descthe text description for the response code
http_versionshould be either "1.0" or "1.1"
headersa hash of headers to send (key: value)
dataoptional message body to send (may be 0)
sizethe length of the message body (may be 0)
sourcethe event source code for socket events
Returns
0 for OK, not 0 for error

◆ sendi1() [1/2]

DLLEXPORT int QoreSocket::sendi1 ( char  i)

sends a 1-byte binary integer data to a connected socket

The socket must be connected before this call is made.

Parameters
ithe 1-byte integer to send through the socket
Returns
0 for OK, not 0 if an error occured

◆ sendi1() [2/2]

DLLEXPORT int QoreSocket::sendi1 ( char  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends a 1-byte binary integer data to a connected socket

The socket must be connected before this call is made.

Parameters
ithe 1-byte integer to send through the socket
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured

◆ sendi2() [1/2]

DLLEXPORT int QoreSocket::sendi2 ( short  i)

sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket

The socket must be connected before this call is made.

Parameters
ithe integer to write to the file
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi2LSB()

◆ sendi2() [2/2]

DLLEXPORT int QoreSocket::sendi2 ( short  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket

The socket must be connected before this call is made.

Parameters
ithe integer to write to the file
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi2LSB()

◆ sendi2LSB() [1/2]

DLLEXPORT int QoreSocket::sendi2LSB ( short  i)

sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::sendi2() should be used
Parameters
ithe integer to write to the file
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi2()

◆ sendi2LSB() [2/2]

DLLEXPORT int QoreSocket::sendi2LSB ( short  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::sendi2() should be used
Parameters
ithe integer to write to the file
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi2()

◆ sendi4() [1/2]

DLLEXPORT int QoreSocket::sendi4 ( int  i)

sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket

The socket must be connected before this call is made.

Parameters
ithe integer to write to the file
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi4LSB()

◆ sendi4() [2/2]

DLLEXPORT int QoreSocket::sendi4 ( int  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket

The socket must be connected before this call is made.

Parameters
ithe integer to write to the file
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi4LSB()

◆ sendi4LSB() [1/2]

DLLEXPORT int QoreSocket::sendi4LSB ( int  i)

sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::sendi4() should be used
Parameters
ithe integer to write to the file
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi4()

◆ sendi4LSB() [2/2]

DLLEXPORT int QoreSocket::sendi4LSB ( int  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::sendi4() should be used
Parameters
ithe integer to write to the file
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi4()

◆ sendi8() [1/2]

DLLEXPORT int QoreSocket::sendi8 ( int64  i)

sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket

The socket must be connected before this call is made.

Parameters
ithe integer to write to the file
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi8LSB()

◆ sendi8() [2/2]

DLLEXPORT int QoreSocket::sendi8 ( int64  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket

The socket must be connected before this call is made.

Parameters
ithe integer to write to the file
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi8LSB()

◆ sendi8LSB() [1/2]

DLLEXPORT int QoreSocket::sendi8LSB ( int64  i)

sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::sendi8() should be used
Parameters
ithe integer to write to the file
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi8()

◆ sendi8LSB() [2/2]

DLLEXPORT int QoreSocket::sendi8LSB ( int64  i,
int  timeout_ms,
ExceptionSink xsink 
)

sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket

The socket must be connected before this call is made.

Note
that this is not network byte order, normally QoreSocket::sendi8() should be used
Parameters
ithe integer to write to the file
timeout_msthe maximum amount of time the socket can block on a single send as an integer in milliseconds
xsinkif an error occurs in socket communication, the Qore-language exception information will be added here
Returns
0 for OK, not 0 if an error occured
See also
QoreSocket::sendi8()

◆ setEncoding()

DLLEXPORT void QoreSocket::setEncoding ( const QoreEncoding id)

sets the character encoding for strings sent and received with this socket

Parameters
idthe character encoding for strings sent and received with this socket

◆ setSslVerifyMode()

DLLEXPORT void QoreSocket::setSslVerifyMode ( int  mode)

sets the SSL verification mode

If no SSL connection is in place, then the mode is saved for use with future SSL connections.

Parameters
modesee the mode parameter of SSL_set_verify() for details
Since
Qore 0.8.13

◆ shutdown()

DLLEXPORT int QoreSocket::shutdown ( )

calls shutdown on the socket

shuts down the socket for reading and writing, after this call further sends and receives are disallowed until the socket is reopened.

Note
QoreSocket::shutdown() should normally be called before calling this function.
Returns
0 if OK, not 0 on error
See also
QoreSocket::shutdown()

◆ shutdownSSL()

DLLEXPORT int QoreSocket::shutdownSSL ( ExceptionSink xsink)

shuts down an active SSL connection

called implicitly by QoreSocket::close()

Returns
0 if OK, not 0 on error
See also
QoreSocket::close()

◆ startConnect()

DLLEXPORT AbstractPollState * QoreSocket::startConnect ( ExceptionSink xsink,
const char *  name 
)

Starts a non-blocking connection to a socket and returns a status code.

If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::startConnectINET() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::startConnectUNIX() is called.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
namethe name of the socket (either hostname:port or file name)
Returns
a socket poll state object or nullptr in case of an exception or an immediate connection
Since
Qore 1.12

◆ startRecv()

DLLEXPORT AbstractPollState * QoreSocket::startRecv ( ExceptionSink xsink,
size_t  size 
)

Starts a non-blocking receive operation on a connected socket.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
sizethe size of the data to read, must be > 0
Returns
a socket poll state object or nullptr in case of an exception or an immediate receive
Since
Qore 1.12

◆ startRecvUntilBytes()

DLLEXPORT AbstractPollState * QoreSocket::startRecvUntilBytes ( ExceptionSink xsink,
const char *  pattern,
size_t  size 
)

Starts a non-blocking receive operation on a connected socket.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
patternthe bytes to expect that indicate the end of the data, must stay valid for the lifetime of the AbstractPollState object returned
sizethe size of pattern in bytes
Returns
a socket poll state object or nullptr in case of an exception or an immediate receive
Since
Qore 1.12

◆ startSend()

DLLEXPORT AbstractPollState * QoreSocket::startSend ( ExceptionSink xsink,
const char *  data,
size_t  size 
)

Starts a non-blocking send operation on a connected socket.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
datathe data to send, must stay valid for the lifetime of the AbstractPollState object returned
sizethe size of the data to send
Returns
a socket poll state object or nullptr in case of an exception or an immediate send
Since
Qore 1.12

◆ startSslConnect()

DLLEXPORT AbstractPollState * QoreSocket::startSslConnect ( ExceptionSink xsink,
X509 *  cert = nullptr,
EVP_PKEY *  pkey = nullptr 
)

Starts a non-blocking upgrade to an SSL connection on a connected client connection.

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
a socket poll state object or nullptr in case of an exception or an immediate connection
Since
Qore 1.12

◆ upgradeClientToSSL() [1/2]

DLLEXPORT int QoreSocket::upgradeClientToSSL ( X509 *  cert,
EVP_PKEY *  pkey,
ExceptionSink xsink 
)

negotiates an SSL connection from the client side

The socket must be connected before this call is made.

Parameters
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 if OK, not 0 on error

◆ upgradeClientToSSL() [2/2]

DLLEXPORT int QoreSocket::upgradeClientToSSL ( X509 *  cert,
EVP_PKEY *  pkey,
int  timeout_ms,
ExceptionSink xsink 
)

negotiates an SSL connection from the client side

The socket must be connected before this call is made.

Parameters
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
timeout_mstimeout in milliseconds, -1 = never timeout
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 if OK, not 0 on error

◆ upgradeServerToSSL() [1/2]

DLLEXPORT int QoreSocket::upgradeServerToSSL ( X509 *  cert,
EVP_PKEY *  pkey,
ExceptionSink xsink 
)

negotiates an SSL connection from the client side

The socket must be connected before this call is made.

Parameters
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 if OK, not 0 on error

◆ upgradeServerToSSL() [2/2]

DLLEXPORT int QoreSocket::upgradeServerToSSL ( X509 *  cert,
EVP_PKEY *  pkey,
int  timeout_ms,
ExceptionSink xsink 
)

negotiates an SSL connection from the client side

The socket must be connected before this call is made.

Parameters
certthe X509 certificate to use for the connection, may be 0 if no certificate should be used
pkeythe private key to use for the connection, may be 0 if no private key should be used
timeout_mstimeout in milliseconds, -1 = never timeout
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
0 if OK, not 0 on error

The documentation for this class was generated from the following file: