Skip to content

Commit

Permalink
net: sockets: Add SO_ERROR socket option to SOL_SOCKET level
Browse files Browse the repository at this point in the history
Return the last socket error to user.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar authored and cfriedt committed Oct 24, 2023
1 parent fd1c226 commit b864880
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions subsys/net/lib/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,17 @@ int zsock_getsockopt_ctx(struct net_context *ctx, int level, int optname,
switch (level) {
case SOL_SOCKET:
switch (optname) {
case SO_ERROR: {
if (*optlen != sizeof(int)) {
errno = EINVAL;
return -1;
}

*(int *)optval = POINTER_TO_INT(ctx->user_data);

return 0;
}

case SO_TYPE: {
int type = (int)net_context_get_type(ctx);

Expand Down

0 comments on commit b864880

Please sign in to comment.