mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
socket accept report addr:port
This commit is contained in:
@@ -831,7 +831,10 @@ report_accept(struct socket_server *ss, struct socket *s, struct socket_message
|
||||
result->data = NULL;
|
||||
|
||||
void * sin_addr = (u.s.sa_family == AF_INET) ? (void*)&u.v4.sin_addr : (void *)&u.v6.sin6_addr;
|
||||
if (inet_ntop(u.s.sa_family, sin_addr, ss->buffer, sizeof(ss->buffer))) {
|
||||
int sin_port = ntohs((u.s.sa_family == AF_INET) ? u.v4.sin_port : u.v6.sin6_port);
|
||||
char tmp[INET6_ADDRSTRLEN];
|
||||
if (inet_ntop(u.s.sa_family, sin_addr, tmp, sizeof(tmp))) {
|
||||
snprintf(ss->buffer, sizeof(ss->buffer), "%s:%d", tmp, sin_port);
|
||||
result->data = ss->buffer;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user