mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
33 lines
980 B
C
33 lines
980 B
C
#ifndef skynet_socket_h
|
|
#define skynet_socket_h
|
|
|
|
struct skynet_context;
|
|
|
|
#define SKYNET_SOCKET_TYPE_DATA 1
|
|
#define SKYNET_SOCKET_TYPE_CONNECT 2
|
|
#define SKYNET_SOCKET_TYPE_CLOSE 3
|
|
#define SKYNET_SOCKET_TYPE_ACCEPT 4
|
|
#define SKYNET_SOCKET_TYPE_ERROR 5
|
|
|
|
struct skynet_socket_message {
|
|
int type;
|
|
int id;
|
|
int ud;
|
|
char * buffer;
|
|
};
|
|
|
|
void skynet_socket_init();
|
|
void skynet_socket_exit();
|
|
void skynet_socket_free();
|
|
int skynet_socket_poll();
|
|
|
|
int skynet_socket_send(struct skynet_context *ctx, int id, void *buffer, int sz);
|
|
int skynet_socket_listen(struct skynet_context *ctx, const char *host, int port, int backlog);
|
|
int skynet_socket_connect(struct skynet_context *ctx, const char *host, int port);
|
|
int skynet_socket_block_connect(struct skynet_context *ctx, const char *host, int port);
|
|
int skynet_socket_bind(struct skynet_context *ctx, int fd);
|
|
void skynet_socket_close(struct skynet_context *ctx, int id);
|
|
void skynet_socket_start(struct skynet_context *ctx, int id);
|
|
|
|
#endif
|