Commit 628559ad authored by Kenton Varda's avatar Kenton Varda

Add getsockname() and getpeername() methods to AsyncIoStream.

parent c9332ebe
......@@ -190,6 +190,18 @@ public:
KJ_SYSCALL(::setsockopt(fd, level, option, value, length));
}
void getsockname(struct sockaddr* addr, uint* length) override {
socklen_t socklen = *length;
KJ_SYSCALL(::getsockname(fd, addr, &socklen));
*length = socklen;
}
void getpeername(struct sockaddr* addr, uint* length) override {
socklen_t socklen = *length;
KJ_SYSCALL(::getpeername(fd, addr, &socklen));
*length = socklen;
}
Promise<void> waitConnected() {
// Wait until initial connection has completed. This actually just waits until it is writable.
......@@ -1329,6 +1341,12 @@ void AsyncIoStream::getsockopt(int level, int option, void* value, uint* length)
void AsyncIoStream::setsockopt(int level, int option, const void* value, uint length) {
KJ_UNIMPLEMENTED("Not a socket.");
}
void AsyncIoStream::getsockname(struct sockaddr* addr, uint* length) {
KJ_UNIMPLEMENTED("Not a socket.");
}
void AsyncIoStream::getpeername(struct sockaddr* addr, uint* length) {
KJ_UNIMPLEMENTED("Not a socket.");
}
void ConnectionReceiver::getsockopt(int level, int option, void* value, uint* length) {
KJ_UNIMPLEMENTED("Not a socket.");
}
......
......@@ -31,6 +31,8 @@
#include "thread.h"
#include "time.h"
struct sockaddr;
namespace kj {
class UnixEventPort;
......@@ -69,6 +71,16 @@ public:
// Corresponds to getsockopt() and setsockopt() syscalls. Will throw an "unimplemented" exception
// if the stream is not a socket or the option is not appropriate for the socket type. The
// default implementations always throw "unimplemented".
virtual void getsockname(struct sockaddr* addr, uint* length);
virtual void getpeername(struct sockaddr* addr, uint* length);
// Corresponds to getsockname() and getpeername() syscalls. Will throw an "unimplemented"
// exception if the stream is not a socket. The default implementations always throw
// "unimplemented".
//
// Note that we don't provide methods that return NetworkAddress because it usually wouldn't
// be useful. You can't connect() to or listen() on these addresses, obviously, because they are
// ephemeral addresses for a single connection.
};
struct OneWayPipe {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment