| 63 | } |
| 64 | |
| 65 | const char* aio_stream::get_peer(bool full /* = false */) const |
| 66 | { |
| 67 | if (stream_ == NULL) { |
| 68 | return ""; |
| 69 | } |
| 70 | |
| 71 | ACL_VSTREAM* vs = acl_aio_vstream(stream_); |
| 72 | const char* ptr = ACL_VSTREAM_PEER(vs); |
| 73 | |
| 74 | if (ptr == NULL || *ptr == 0) { |
| 75 | char buf[256]; |
| 76 | ACL_SOCKET fd = ACL_VSTREAM_SOCK(vs); |
| 77 | |
| 78 | if (acl_getpeername(fd, buf, sizeof(buf)) == -1) { |
| 79 | return ""; |
| 80 | } |
| 81 | acl_vstream_set_peer(vs, buf); |
| 82 | } |
| 83 | |
| 84 | ptr = ACL_VSTREAM_PEER(vs); |
| 85 | if (full) { |
| 86 | return ptr; |
| 87 | } |
| 88 | |
| 89 | return const_cast<aio_stream*> |
| 90 | (this)->get_ip(ptr, const_cast<aio_stream*>(this)->ip_peer_); |
| 91 | } |
| 92 | |
| 93 | const char* aio_stream::get_local(bool full /* = false */) const |
| 94 | { |