Hi,
For "off the chart" networking programs, we need an empty service in Linux with SOCK_RAW, otherwise, it keeps bothering with /etc/services, which we don't want.
so, in nativesockets.nim
@@ -251,13 +251,14 @@
# FreeBSD, Haiku don't support AI_V4MAPPED but defines the macro.
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092
# https://dev.haiku-os.org/ticket/14323
-
when not defined(freebsd) and not defined(openbsd) and not defined(netbsd) and not defined(android) and not defined(haiku):
if domain == AF_INET6:
hints.ai_flags = AI_V4MAPPED
-
- var gaiResult = getaddrinfo(address, $port, addr(hints), result)
-
+ var gaiResult : int32 = 0
+ if (sockType == SOCK_RAW):
+ gaiResult = getaddrinfo(address, "", addr(hints), result)
+ else:
+ gaiResult = getaddrinfo(address, $port, addr(hints), result)
if gaiResult != 0'i32:
when useWinVersion:
raiseOSError(osLastError())
And BTW, we should have a mean to cache the result of getaddrinfo, avoiding to call it everytime we sendTo.. Or better, for those who care, having different functions with provided hints. Should I look into it?
Thanks
dom96,
To achieve the real raw sockets, I need platform specific files. For example, I need some definitions which are inside /usr/include/in.h It leads to platform specific constants. (/usr/include/x86_64-linux-gnu/bits/).
What is the best -nim- strategy to let nim automatically detect those important constants?