Skip to content

socket_addrinfo_lookup no way to get return code #20532

@murrant

Description

@murrant

Description

I need to differentiate between different kinds of host lookup failures. getaddrinfo() includes the following return codes I am interested in: EAI_AGAIN, EAI_FAIL, EAI_FAMILY, EAI_NODATA, EAI_NONAME (and the others might be helpful for others)

Currently there is no way to get the return code.

My instinctual attempt to get the error was to try socket_last_error(), but this always returns 0 (Success).

I then took a look at the source code and the return code is not retained. All non-zero return codes just return false without storing the error code in any way.

In sockets.c:

if (getaddrinfo(ZSTR_VAL(hostname), service, &hints, &result) != 0) {
	RETURN_FALSE;
}

Is there any way to get the error code currently? Would new code need to be implemented to allow access to the error codes?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions