elaphureLinkProxy provides a set of API for managing the establishment and disconnection of connections, as well as callback functions for when connection establishment and disconnection events occur.
If not specified, all functions are thread unsafe.
All exported functions use the cdelc calling convention.
The following simple example shows how to connect to the Proxy and set the callback function when connection disconnect.
#include <stdio.h>
#include <windows.h>
void on_proxy_disconnect_callback(const char* msg)
{
printf("proxy exit. Reason: %s\n", msg);
exit(0);
}
int start_proxy(char* proxy_address)
{
int ret;
ret = el_proxy_init();
if (ret != 0) {
printf("Could not start proxy. Exit.\n");
return ret; // failed
}
ret = el_proxy_start_with_address(proxy_address);
if (ret != 0) {
return ret; // failed
}
el_proxy_set_on_disconnect_callback(on_proxy_disconnect_callback);
return 0;
}
int main()
{
int ret;
ret = start_proxy("dap.local");
if (ret = 0) {
exit(1); // failed
}
Sleep(INFINITE); // wait proxy thread to exit.
return 0;
}
Initialize proxy resources, must call it at the beginning.
int el_proxy_init();
return 0 on success, other on fail.
Start the Proxy with the specified address.
int el_proxy_start_with_address(char *address);
return 0 on success, other on fail.
Force the Proxy to stop. This function can be used at any time.
void el_proxy_stop();
Set the callback function to be used when the Proxy connection is successfully established.
void el_proxy_set_on_connect_callback(onSocketConnectCallbackType callback);
Set the callback function to be used when the Proxy connection is disconnected.
void el_proxy_set_on_disconnect_callback(onSocketDisconnectCallbackType callback);
typedef void (*onSocketConnectCallbackType)(const char* msg);
msg
is a string message provided by the proxy to the callback function about the reason for the establishment.
typedef void (*onSocketDisconnectCallbackType)(const char* msg);
msg
is a string message provided by the proxy to the callback function about the reason for the disconnection.