# tok2c **Repository Path**: qiled_admin/tok2c ## Basic Information - **Project Name**: tok2c - **Description**: 高性能socket库(易语言专用) - **Primary Language**: Rust - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-04 - **Last Updated**: 2024-08-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # tok2c <<<<<<< HEAD > To compile the toolset to vc2017, you need to install the vc2017 runtime library ## Example ``` void on_connect(int32 conn_id) { printf("on_connect: %d", conn_id); } void on_receive(int32 conn_id, char* msg, usize msg_len) { printf("on_receive: %d|%d|%d", conn_id, msg, msg_len); } void on_close(int32 conn_id) { printf("on_close: %d", conn_id); } void on_fail(int32 conn_id) { printf("on_fail: %d", conn_id); } void on_run() { // If domain is empty, it means normal tcp, if it is not empty, it means tls is enabled. int32 conn_id = tcp_connect("www.baidu.com:443", "www.baidu.com", on_connect, on_receive, on_close, on_fail); sleep(999999999); } void main() { schedule_run(5, 10, 5*1024*1024, on_run); } ``` ## Schedule typedef void (__stdcall*OnRun)(); schedule_run(usize worker_threads, usize max_blocking_threads, usize thread_stack_size, OnRun on_run) -> void; schedule_spawn(OnTask task, int32 arg) -> void; ## Websocket typedef void (__stdcall*WebSocketOnConnection)(int32 conn_id); typedef void (__stdcall*WebSocketOnReceive)(int32 conn_id, char* msg, usize msg_len); typedef void (__stdcall*WebSocketOnClose)(int32 conn_id); typedef void (__stdcall*WebSocketOnConnectFail)(int32 conn_id); ws_connect(char* url, KVPair* headers, usize headers_size, on_connect: WebSocketOnConnection, on_receive: WebSocketOnReceive, on_close: WebSocketOnClose, on_fail: WebSocketOnConnectFail) -> int32; ws_disconnect(int32 conn_id) -> bool; ws_send_text(int32 conn_id, char* msg, usize msg_len) -> bool; ws_send_binary(int32 conn_id, char* msg, usize msg_len) -> bool; ws_send_ping(int32 conn_id, char* msg, usize msg_len) -> bool; ws_send_pong(int32 conn_id, char* msg, usize msg_len) -> bool; ## TcpSocket typedef void (__stdcall*TcpSocketOnConnection)(int32 conn_id); typedef void (__stdcall*TcpSocketOnReceive)(int32 conn_id, char* msg, usize msg_len); typedef void (__stdcall*TcpSocketOnClose)(int32 conn_id); typedef void (__stdcall*TcpSocketOnConnectFail)(int32 conn_id); tcp_connect(char* address, char* domain, on_connect: TcpSocketOnConnection, on_receive: TcpSocketOnReceive, on_close: TcpSocketOnClose, on_fail: TcpSocketOnConnectFail) -> int32; tcp_disconnect(int32 conn_id) -> bool; tcp_send_data(int32 conn_id, char* msg, usize msg_len) -> bool; ======= > 高性能的sock库,专门为易语言定制的 代码不会实时更新,D-websocket里面的tok2c一般为最新测试版 >>>>>>> develop