Skip to content

windows mingw compile hsocket.c error #14

@yulunyue

Description

@yulunyue

#hscoket.h
static inline const char* sockaddr_ip(sockaddr_u* addr, char* ip, int len) {
if (addr->sa.sa_family == AF_INET) {
return inet_ntop(AF_INET, &addr->sin.sin_addr, ip, len);
}
else if (addr->sa.sa_family == AF_INET6) {
return inet_ntop(AF_INET6, &addr->sin6.sin6_addr, ip, len);
}
return ip;
}

#hsocket.c
int Resolver(const char* host, sockaddr_u* addr) {
if (inet_pton(AF_INET, host, &addr->sin.sin_addr) == 1) {
addr->sa.sa_family = AF_INET; // host is ipv4, so easy ;)
return 0;
}

inet_ntop 返回值是 char 还是 int 呢

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions