mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
Add socket_sendbuffer
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "socket_info.h"
|
||||
#include "socket_buffer.h"
|
||||
|
||||
#define SOCKET_DATA 0
|
||||
#define SOCKET_CLOSE 1
|
||||
@@ -33,8 +34,8 @@ void socket_server_shutdown(struct socket_server *, uintptr_t opaque, int id);
|
||||
void socket_server_start(struct socket_server *, uintptr_t opaque, int id);
|
||||
|
||||
// return -1 when error
|
||||
int socket_server_send(struct socket_server *, int id, const void * buffer, int sz);
|
||||
int socket_server_send_lowpriority(struct socket_server *, int id, const void * buffer, int sz);
|
||||
int socket_server_send(struct socket_server *, struct socket_sendbuffer *buffer);
|
||||
int socket_server_send_lowpriority(struct socket_server *, struct socket_sendbuffer *buffer);
|
||||
|
||||
// ctrl command below returns id
|
||||
int socket_server_listen(struct socket_server *, uintptr_t opaque, const char * addr, int port, int backlog);
|
||||
@@ -53,17 +54,17 @@ int socket_server_udp(struct socket_server *, uintptr_t opaque, const char * add
|
||||
int socket_server_udp_connect(struct socket_server *, int id, const char * addr, int port);
|
||||
// If the socket_udp_address is NULL, use last call socket_server_udp_connect address instead
|
||||
// You can also use socket_server_send
|
||||
int socket_server_udp_send(struct socket_server *, int id, const struct socket_udp_address *, const void *buffer, int sz);
|
||||
int socket_server_udp_send(struct socket_server *, const struct socket_udp_address *, struct socket_sendbuffer *buffer);
|
||||
// extract the address of the message, struct socket_message * should be SOCKET_UDP
|
||||
const struct socket_udp_address * socket_server_udp_address(struct socket_server *, struct socket_message *, int *addrsz);
|
||||
|
||||
struct socket_object_interface {
|
||||
void * (*buffer)(void *);
|
||||
int (*size)(void *);
|
||||
const void * (*buffer)(const void *);
|
||||
size_t (*size)(const void *);
|
||||
void (*free)(void *);
|
||||
};
|
||||
|
||||
// if you send package sz == -1, use soi.
|
||||
// if you send package with type SOCKET_BUFFER_OBJECT, use soi.
|
||||
void socket_server_userobject(struct socket_server *, struct socket_object_interface *soi);
|
||||
|
||||
struct socket_info * socket_server_info(struct socket_server *);
|
||||
|
||||
Reference in New Issue
Block a user