mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
add UDP support, and TCP listen support ipv6 now
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#define SOCKET_ACCEPT 3
|
||||
#define SOCKET_ERROR 4
|
||||
#define SOCKET_EXIT 5
|
||||
#define SOCKET_UDP 6
|
||||
|
||||
struct socket_server;
|
||||
|
||||
@@ -36,8 +37,22 @@ int socket_server_listen(struct socket_server *, uintptr_t opaque, const char *
|
||||
int socket_server_connect(struct socket_server *, uintptr_t opaque, const char * addr, int port);
|
||||
int socket_server_bind(struct socket_server *, uintptr_t opaque, int fd);
|
||||
|
||||
// for tcp
|
||||
void socket_server_nodelay(struct socket_server *, int id);
|
||||
|
||||
struct socket_udp_address;
|
||||
|
||||
// create an udp socket handle, attach opaque with it . udp socket don't need call socket_server_start to recv message
|
||||
// if port != 0, bind the socket . if addr == NULL, bind ipv4 0.0.0.0 . If you want to use ipv6, addr can be "::" and port 0.
|
||||
int socket_server_udp(struct socket_server *, uintptr_t opaque, const char * addr, int port);
|
||||
// set default dest address, return 0 when success
|
||||
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
|
||||
int64_t socket_server_udp_send(struct socket_server *, int id, const struct socket_udp_address *, const void *buffer, int sz);
|
||||
// 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 *);
|
||||
|
||||
Reference in New Issue
Block a user