LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
c4Socket.h
Go to the documentation of this file.
1//
2// c4Socket.h
3//
4// Copyright 2017-Present Couchbase, Inc.
5//
6// Use of this software is governed by the Business Source License included
7// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
8// in that file, in accordance with the Business Source License, use of this
9// software will be governed by the Apache License, Version 2.0, included in
10// the file licenses/APL2.txt.
11//
12
13#pragma once
14#include "c4SocketTypes.h"
15
18
21
22
23// NOTE: C4Socket used to be a concrete struct containing a single field `nativeHandle`.
24// As part of creating the C++ API, this struct declaration was removed so it could be
25// declared in c4Struct.hh as a real C++ object.
26// To fix client code that accessed `nativeHandle` directly, call `c4Socket_setNativeHandle`
27// and/or `c4Socket_setNativeHandle` instead.
28
29
33
38
42
63
77CBL_CORE_API void c4socket_gotHTTPResponse(C4Socket* socket, int httpStatus, C4Slice responseHeadersFleece) C4API;
78
84
95
104CBL_CORE_API void c4socket_closeRequested(C4Socket* socket, int status, C4String message) C4API;
105
111CBL_CORE_API void c4socket_completedWrite(C4Socket* socket, size_t byteCount) C4API;
112
124
125
127 const C4Address* address) C4API;
128
140 const C4Address* address, bool incoming) C4API;
141
143
#define NODISCARD
Definition CompilerSupport.h:63
#define CBL_CORE_API
Definition c4Compat.h:131
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:106
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:108
#define C4API_BEGIN_DECLS
Definition c4Compat.h:107
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
C4Slice C4String
Definition c4Base.h:51
FLSlice C4Slice
Definition c4Base.h:48
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition c4Base.h:183
CBL_CORE_API void c4socket_closeRequested(C4Socket *socket, int status, C4String message)
Notifies LiteCore that the peer has requested to close the socket using the WebSocket protocol.
CBL_CORE_API void c4socket_closed(C4Socket *socket, C4Error errorIfAny)
Notifies LiteCore that a socket has finished closing, or disconnected, or failed to open.
CBL_CORE_API void c4socket_completedWrite(C4Socket *socket, size_t byteCount)
Notifies LiteCore that a C4SocketFactory.write request has been completed, i.e.
CBL_CORE_API void c4socket_gotHTTPResponse(C4Socket *socket, int httpStatus, C4Slice responseHeadersFleece)
Notification that a client socket has received an HTTP response, with the headers encoded as a Fleece...
CBL_CORE_API void c4socket_opened(C4Socket *socket)
Notifies LiteCore that a socket has opened, i.e.
CBL_CORE_API bool c4socket_gotPeerCertificate(C4Socket *socket, C4Slice certData, C4String hostname)
Notifies LiteCore that a socket is making a TLS connection and has received the peer's (usually serve...
CBL_CORE_API void c4socket_received(C4Socket *socket, C4Slice data)
Notifies LiteCore that data was received from the socket.
CBL_CORE_API void c4socket_registerFactory(C4SocketFactory factory)
One-time registration of default socket callbacks.
NODISCARD CBL_CORE_API C4Socket * c4socket_fromNative(C4SocketFactory factory, void *nativeHandle, const C4Address *address)
CBL_CORE_API void c4Socket_setNativeHandle(C4Socket *, void *)
Associates an opaque "native handle" with this object.
CBL_CORE_API void * c4Socket_getNativeHandle(C4Socket *)
Returns the opaque "native handle" associated with this object.
NODISCARD CBL_CORE_API C4Socket * c4socket_fromNative2(C4SocketFactory factory, void *nativeHandle, const C4Address *address, bool incoming)
Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory.
A simple parsed-URL type.
Definition c4ReplicatorTypes.h:57
An error value.
Definition c4Error.h:133
A group of callbacks that define the implementation of sockets; the client must fill this out and pas...
Definition c4SocketTypes.h:59