代码拉取完成,页面将自动刷新
//
// Created by zkm on 2025/5/20.
#ifndef CLI_CORE_H
#define CLI_CORE_H
#include <threads.h>
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <winsock2.h>
#include <ws2tcpip.h>
typedef struct Server
{
SOCKET sock;
} SERVER;
typedef struct CallbackFn_Params
{
SOCKET sock;
int (*callback)(const char*, int len);
} CALLBACK_FN_PARAMS;
/**
* Initializes locale and Windows socket.
* MUST be called first.
*
* Exception: WSA network error.
* @return 0: success; WSA error code: failure.
*/
int cli_core_init();
/**
* Cleans up client.
* MUST be called prior to exiting.
*
* Exception: WSA network error.
* @return 0: success; WSA error code: failure.
*/
int cli_core_cleanup();
/**
* Initialize a SERVER instance.
* The returned SERVER instance must be freed by cli_core_logout.
* @param ip IPv4 address string to the server.
* @param port Port of the server.
* @param callback Function to be called when new msg arrives.
* @param wsa_error Pointer to an integer, to store WSA error code, or 0 if there are no WSA errors.
* @return Pointer to a SERVER instance: success; NULL: failure.
*/
SERVER* cli_core_login(const char* ip, int port, int (*callback)(const char*, int len), int* wsa_error);
/**
* Sends a message to the LAN.
* @param server Pointer to a SERVER instance.
* @param msg Message to be sent, in string.
* @param len Length (bytes) of the message string.
* @return 0: success; WSA error code: WSA failure; -1: internal error.
*/
int cli_core_send(SERVER *server, const char *msg, int len);
/**
* Disconnect client from server.
* The SERVER instance will be freed and set to NULL.
* @param server Pointer to a SERVER instance that has been initialized by cli_core_login.
* @return 0: success, -1: internal error.
*/
int cli_core_logout(SERVER *server);
#endif //CLI_CORE_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。