MCPcopy Create free account
hub / github.com/Tencent/phxsql / SetAddr6

Function SetAddr6

phxsqlproxy/phxsqlproxyutil.cpp:79–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79int SetAddr6(const char * ip_string, const unsigned short port, struct sockaddr_in6 & addr) {
80 bzero(&addr, sizeof(addr));
81 addr.sin6_family = AF_INET6;
82 addr.sin6_port = htons(port);
83 if (!ip_string || '\0' == *ip_string || 0 == strcmp(ip_string, "0") || 0 == strcmp(ip_string, "::")
84 || 0 == strcmp(ip_string, "*")) {
85 addr.sin6_addr = in6addr_any;
86 } else {
87 int ret = inet_pton(AF_INET6, ip_string, &addr.sin6_addr);
88 if (ret <= 0) {
89 LogError("inet_pton failed, ip [%s], ret %d, errno(%d:%s)", ip_string, ret, errno, strerror(errno));
90 return -1;
91 }
92 }
93 return 0;
94}
95
96int CreateTcpSocket(const unsigned short port /* = 0 */, const char *ip /* = "*" */, bool is_reuse /* = false */) {
97 int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

Callers 1

ParseProxyHeaderV1Method · 0.85

Calls 1

LogErrorFunction · 0.85

Tested by

no test coverage detected