diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp b/src/add-ons/kernel/network/stack/net_socket.cpp index 4ca9ebbf20..03297b92d3 100644 --- a/src/add-ons/kernel/network/stack/net_socket.cpp +++ b/src/add-ons/kernel/network/stack/net_socket.cpp @@ -1059,10 +1059,11 @@ socket_connect(net_socket* socket, const struct sockaddr* address, int -socket_getpeername(net_socket* socket, struct sockaddr* address, +socket_getpeername(net_socket* _socket, struct sockaddr* address, socklen_t* _addressLength) { - if (socket->peer.ss_len == 0) + net_socket_private* socket = (net_socket_private*)_socket; + if (!socket->is_connected || socket->peer.ss_len == 0) return ENOTCONN; memcpy(address, &socket->peer, min_c(*_addressLength, socket->peer.ss_len));