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

Function GetPeerName

phxsqlproxy/phxsqlproxyutil.cpp:191–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191int GetPeerName(int fd, std::string & ip, int & port) {
192 struct sockaddr_storage addr_storage;
193 struct sockaddr * addr = (struct sockaddr *) &addr_storage;
194 socklen_t sock_len = sizeof(addr_storage);
195
196 int ret = getpeername(fd, addr, &sock_len);
197 if (ret == -1) {
198 LogError("getpeername fd [%d] failed, ret %d, errno (%d:%s)", fd, ret, errno, strerror(errno));
199 return -__LINE__;
200 }
201
202 return SockAddrToIPPort(addr, ip, port);
203}
204
205uint64_t DecodedLengthBinary(const char * buf, int len, int & len_field_size) {
206 uint8_t first_bit = (uint8_t)(buf[0]);

Callers 1

TransMsgMethod · 0.85

Calls 2

LogErrorFunction · 0.85
SockAddrToIPPortFunction · 0.85

Tested by

no test coverage detected