Merge pull request #38 from TheBlueMatt/main
[ldk-c-bindings] / ldk-net / ldk_net.h
1 #include "lightning.h"
2 #include <sys/socket.h>
3 /**
4  * Initializes socket handling and spawns a background thread to handle socket
5  * events and pass them to the given LDKPeerManager.
6  *
7  * Returns NULL on error, otherwise an opaque pointer which should be passed as
8  * `handler` in the remaining functions.
9  */
10 void* init_socket_handling(const struct LDKPeerManager *NONNULL_PTR ldk_peer_manger);
11 /**
12  * Stop the socket handling thread and free socket handling resources for the
13  * given handler, as returned by init_socket_handling.
14  */
15 void interrupt_socket_handling(void* handler);
16 /**
17  * Bind the given address to accept incoming connections on the given handler's
18  * background thread.
19  * Returns 0 on success.
20  */
21 int socket_bind(void* handler, struct sockaddr *addr, socklen_t addrlen);
22 /**
23  * Connect to the given address and handle socket events on the given handler's
24  * background thread.
25  * Returns 0 on success.
26  */
27 int socket_connect(void* handler, LDKPublicKey counterparty_pubkey, struct sockaddr *addr, size_t addrlen);