mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
@@ -648,13 +648,12 @@ ludp(lua_State *L) {
|
|||||||
host = address_port(L, tmp, addr, 2, &port);
|
host = address_port(L, tmp, addr, 2, &port);
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = skynet_socket_udp(ctx, host, &port);
|
int id = skynet_socket_udp(ctx, host, port);
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
return luaL_error(L, "udp init failed");
|
return luaL_error(L, "udp init failed");
|
||||||
}
|
}
|
||||||
lua_pushinteger(L, id);
|
lua_pushinteger(L, id);
|
||||||
lua_pushinteger(L, port);
|
return 1;
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ skynet_socket_nodelay(struct skynet_context *ctx, int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
skynet_socket_udp(struct skynet_context *ctx, const char * addr, int *port) {
|
skynet_socket_udp(struct skynet_context *ctx, const char * addr, int port) {
|
||||||
uint32_t source = skynet_context_handle(ctx);
|
uint32_t source = skynet_context_handle(ctx);
|
||||||
return socket_server_udp(SOCKET_SERVER, source, addr, port);
|
return socket_server_udp(SOCKET_SERVER, source, addr, port);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void skynet_socket_start(struct skynet_context *ctx, int id);
|
|||||||
void skynet_socket_pause(struct skynet_context *ctx, int id);
|
void skynet_socket_pause(struct skynet_context *ctx, int id);
|
||||||
void skynet_socket_nodelay(struct skynet_context *ctx, int id);
|
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(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_connect(struct skynet_context *ctx, int id, const char * addr, int port);
|
||||||
int skynet_socket_udp_sendbuffer(struct skynet_context *ctx, const char * address, struct socket_sendbuffer *buffer);
|
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);
|
const char * skynet_socket_udp_address(struct skynet_socket_message *, int *addrsz);
|
||||||
|
|||||||
@@ -2070,7 +2070,7 @@ socket_server_userobject(struct socket_server *ss, struct socket_object_interfac
|
|||||||
// UDP
|
// UDP
|
||||||
|
|
||||||
int
|
int
|
||||||
socket_server_udp(struct socket_server *ss, uintptr_t opaque, const char * addr, int *port) {
|
socket_server_udp(struct socket_server *ss, uintptr_t opaque, const char * addr, int port) {
|
||||||
int fd;
|
int fd;
|
||||||
int family;
|
int family;
|
||||||
if (port != 0 || addr != NULL) {
|
if (port != 0 || addr != NULL) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ 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
|
// 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.
|
// 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);
|
int socket_server_udp(struct socket_server *, uintptr_t opaque, const char * addr, int port);
|
||||||
// set default dest address, return 0 when success
|
// set default dest address, return 0 when success
|
||||||
int socket_server_udp_connect(struct socket_server *, int id, const char * addr, int port);
|
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
|
// If the socket_udp_address is NULL, use last call socket_server_udp_connect address instead
|
||||||
|
|||||||
Reference in New Issue
Block a user