Skip to content

Commit

Permalink
utils: apply QNX getaddrinfo workaround (closes #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
afflux committed Aug 31, 2023
1 parent b9a50b6 commit a33c622
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/someip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import functools
import platform
import socket
import typing

Expand Down Expand Up @@ -60,13 +61,25 @@ async def getfirstaddrinfo(
proto = sock.proto
if loop is None: # pragma: nobranch
loop = asyncio.get_event_loop()

# QNX fails when supplying a numeric port to getaddrinfo
# workaround: supply no port and inject it in the results instead
# see https://github.com/afflux/pysomeip/issues/13
no_port_in_gai = platform.system() == "QNX"
lookup_port = None if no_port_in_gai else port

result = await loop.getaddrinfo(
host, port, family=family, type=type, proto=proto, flags=flags
host, lookup_port, family=family, type=type, proto=proto, flags=flags
)

if not result: # pragma: nocover
raise socket.gaierror(
socket.EAI_NODATA, f"no address info found for {host}:{port}"
)

if no_port_in_gai: # pragma: nocover
result = result[:1] + (port,) + result[2:]

return result[0]


Expand Down

0 comments on commit a33c622

Please sign in to comment.