mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
Add socket_sendbuffer
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define skynet_socket_h
|
||||
|
||||
#include "socket_info.h"
|
||||
#include "socket_buffer.h"
|
||||
|
||||
struct skynet_context;
|
||||
|
||||
@@ -26,8 +27,8 @@ void skynet_socket_free();
|
||||
int skynet_socket_poll();
|
||||
void skynet_socket_updatetime();
|
||||
|
||||
int skynet_socket_send(struct skynet_context *ctx, int id, void *buffer, int sz);
|
||||
int skynet_socket_send_lowpriority(struct skynet_context *ctx, int id, void *buffer, int sz);
|
||||
int skynet_socket_sendbuffer(struct skynet_context *ctx, struct socket_sendbuffer *buffer);
|
||||
int skynet_socket_sendbuffer_lowpriority(struct skynet_context *ctx, struct socket_sendbuffer *buffer);
|
||||
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_bind(struct skynet_context *ctx, int fd);
|
||||
@@ -38,9 +39,40 @@ void skynet_socket_nodelay(struct skynet_context *ctx, int id);
|
||||
|
||||
int skynet_socket_udp(struct skynet_context *ctx, const char * addr, int port);
|
||||
int skynet_socket_udp_connect(struct skynet_context *ctx, int id, const char * addr, int port);
|
||||
int skynet_socket_udp_send(struct skynet_context *ctx, int id, const char * address, const void *buffer, int sz);
|
||||
int skynet_socket_udp_sendbuffer(struct skynet_context *ctx, const char * address, struct socket_sendbuffer *buffer);
|
||||
const char * skynet_socket_udp_address(struct skynet_socket_message *, int *addrsz);
|
||||
|
||||
struct socket_info * skynet_socket_info();
|
||||
|
||||
// legacy APIs
|
||||
|
||||
static inline void sendbuffer_init_(struct socket_sendbuffer *buf, int id, const void *buffer, int sz) {
|
||||
buf->id = id;
|
||||
buf->buffer = buffer;
|
||||
if (sz < 0) {
|
||||
buf->type = SOCKET_BUFFER_OBJECT;
|
||||
} else {
|
||||
buf->type = SOCKET_BUFFER_MEMORY;
|
||||
}
|
||||
buf->sz = (size_t)sz;
|
||||
}
|
||||
|
||||
static inline int skynet_socket_send(struct skynet_context *ctx, int id, void *buffer, int sz) {
|
||||
struct socket_sendbuffer tmp;
|
||||
sendbuffer_init_(&tmp, id, buffer, sz);
|
||||
return skynet_socket_sendbuffer(ctx, &tmp);
|
||||
}
|
||||
|
||||
static inline int skynet_socket_send_lowpriority(struct skynet_context *ctx, int id, void *buffer, int sz) {
|
||||
struct socket_sendbuffer tmp;
|
||||
sendbuffer_init_(&tmp, id, buffer, sz);
|
||||
return skynet_socket_sendbuffer_lowpriority(ctx, &tmp);
|
||||
}
|
||||
|
||||
static inline int skynet_socket_udp_send(struct skynet_context *ctx, int id, const char * address, const void *buffer, int sz) {
|
||||
struct socket_sendbuffer tmp;
|
||||
sendbuffer_init_(&tmp, id, buffer, sz);
|
||||
return skynet_socket_udp_sendbuffer(ctx, address, &tmp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user