summary refs log tree commit diff stats
path: root/lib/pure/nativesockets.nim
Commit message (Collapse)AuthorAgeFilesLines
* devel: style fix (#19318)Ștefan Talpalaru2022-01-041-1/+1
| | | this allows "--styleCheck:usages --styleCheck:error"
* Add Zephyr Support (#19003)Jaremy Creechley2021-10-241-262/+343
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Porting Nim to run on Zephyr. Includes changes to `std/net`. Squashed commit of the following: tweaking more memory / malloc things revert back bitmasks tweaking nim to use kernel heap as C malloc doesn't work fixing socket polling on zephyr cleanup getting maximum sockets for process or for rtos'es reorganizing and fixing net for async / system merge netlite changes back into nativesockets merge netlite changes back into nativesockets reverting native sockets back tweaking nim / zephyr network adding option to run 'net-lite' from linux bridging zephyr's max connections fixing net errors fixing compilation with getAddrString fixing compilation with getAddrString experimenting with a nativesockets_lite ... getAddrString experimenting with a nativesockets_lite ... getAddrString experimenting with a nativesockets_lite ... getLocalAddr experimenting with a nativesockets_lite ... getLocalAddr experimenting with a nativesockets_lite ... add note regarding incorrect FreeRTOS Sockadd_in fields changing to NIM_STATIC_ASSERT cleaning up the static_assert error messages cleaning up the static_assert error messages setting up static assert ftw! testing compile time asserts reworking Sockaddr objects to more closely match various platforms reworking Sockaddr objects to more closely match various platforms reworking Sockaddr objects to more closely match various platforms finding missing items (issue #18684) fixup posix constants (issue #18684) adding plumbing for zephyr os (issue #18684) adding plumbing for zephyr os (issue #18684) * fixing constant capitalizations * remove extra debug prints and fix TSa_Family/cint issue * remove extra debug prints and fix TSa_Family/cint issue * Porting Nim to run on Zephyr. Includes changes to `std/net`. Squashed commit of the following: tweaking more memory / malloc things revert back bitmasks tweaking nim to use kernel heap as C malloc doesn't work fixing socket polling on zephyr cleanup getting maximum sockets for process or for rtos'es reorganizing and fixing net for async / system merge netlite changes back into nativesockets merge netlite changes back into nativesockets reverting native sockets back tweaking nim / zephyr network adding option to run 'net-lite' from linux bridging zephyr's max connections fixing net errors fixing compilation with getAddrString fixing compilation with getAddrString experimenting with a nativesockets_lite ... getAddrString experimenting with a nativesockets_lite ... getAddrString experimenting with a nativesockets_lite ... getLocalAddr experimenting with a nativesockets_lite ... getLocalAddr experimenting with a nativesockets_lite ... add note regarding incorrect FreeRTOS Sockadd_in fields changing to NIM_STATIC_ASSERT cleaning up the static_assert error messages cleaning up the static_assert error messages setting up static assert ftw! testing compile time asserts reworking Sockaddr objects to more closely match various platforms reworking Sockaddr objects to more closely match various platforms reworking Sockaddr objects to more closely match various platforms finding missing items (issue #18684) fixup posix constants (issue #18684) adding plumbing for zephyr os (issue #18684) adding plumbing for zephyr os (issue #18684) * fixing constant capitalizations * remove extra debug prints and fix TSa_Family/cint issue * remove extra debug prints and fix TSa_Family/cint issue * fixing PR issues * Porting Nim to run on Zephyr. Includes changes to `std/net`. Squashed commit of the following: tweaking more memory / malloc things revert back bitmasks tweaking nim to use kernel heap as C malloc doesn't work fixing socket polling on zephyr cleanup getting maximum sockets for process or for rtos'es reorganizing and fixing net for async / system merge netlite changes back into nativesockets merge netlite changes back into nativesockets reverting native sockets back tweaking nim / zephyr network adding option to run 'net-lite' from linux bridging zephyr's max connections fixing net errors fixing compilation with getAddrString fixing compilation with getAddrString experimenting with a nativesockets_lite ... getAddrString experimenting with a nativesockets_lite ... getAddrString experimenting with a nativesockets_lite ... getLocalAddr experimenting with a nativesockets_lite ... getLocalAddr experimenting with a nativesockets_lite ... add note regarding incorrect FreeRTOS Sockadd_in fields changing to NIM_STATIC_ASSERT cleaning up the static_assert error messages cleaning up the static_assert error messages setting up static assert ftw! testing compile time asserts reworking Sockaddr objects to more closely match various platforms reworking Sockaddr objects to more closely match various platforms reworking Sockaddr objects to more closely match various platforms finding missing items (issue #18684) fixup posix constants (issue #18684) adding plumbing for zephyr os (issue #18684) adding plumbing for zephyr os (issue #18684) * fixing constant capitalizations * remove extra debug prints and fix TSa_Family/cint issue * remove extra debug prints and fix TSa_Family/cint issue * Remerge * fixing constant capitalizations * remove extra debug prints and fix TSa_Family/cint issue * remove extra debug prints and fix TSa_Family/cint issue * fixing PR issues * fix maxDescriptors on zephyr/freertos * move maxDescriptors to selector.nim -- fixes compile issue * change realloc impl on zephyr to match ansi c behavior * change realloc impl on zephyr to match ansi c behavior * force compileOnly mode for tlwip Co-authored-by: Jaremy J. Creechley <jaremy.creechley@wavebaselabs.com> Co-authored-by: Jaremy Creechley <jaremy.creechley@panthalassa.com>
* [minor] reduce `substr` (#18611)flywind2021-07-301-4/+6
| | | | | | | | | * minor * correct * unify the type of addrLen * Update lib/packages/docutils/rstgen.nim
* fixes #18088 (#18209)Andreas Rumpf2021-06-071-1/+1
|
* Use `.. warning::` (#17320)konsumlamm2021-03-101-3/+3
|
* use lowercase --define switches (#17283)flywind2021-03-071-2/+2
|
* Replace double backticks with single backticks - Part 3 out of ~7 (#17207)Danil Yarantsev2021-02-281-28/+28
|
* styleCheck: Fix some inconsistent identifiers (#16177)ee72020-12-211-1/+1
|
* add getprotobyname (#15273)flywind2020-09-091-0/+14
| | | | | | | * add getprotobyname * tests, docs, changelog * add since
* nativesockets docs minor [backport: 1.2] (#15285)flywind2020-09-081-9/+9
|
* more Protocol supports in windows (#15274) [backport:1.2]flywind2020-09-071-5/+19
|
* Changes for FreeRTOS/LwIP Port for the ESP32 (ESP-IDF) (#15250)Jaremy Creechley2020-08-311-1/+1
| | | | | | | | | | | | | | | | | | | * Changes for FreeRTOS/LwIP Port for the ESP32 (ESP-IDF) Adding FreeRTOS/LwIP to compiler: * adding freertos option * dyncalls for freertos * add freertos to posix os list * adding lwip option Setting up networking FreeRTOS/LwIP Port: * setting up lwip network for freertos * fixing posix / networking for freertos * disable setInheritable for freerots * using lwip for net control items * Fix builds by ignoring lib/posix/posix_freertos_consts.nim similar to lib/posix/posix_other_consts.nim
* fix docs for nativesocket read/write selects (#15010)Andy Davidoff2020-07-181-2/+2
| | | The sockets which *cannot* be _[read from or written to]_ will also be removed from ``readfds``.
* add a second asyncnet.recvFrom (#14237)rockcavera2020-06-271-0/+34
| | | | | | | | | * add a second asyncnet.recvFrom * fixes * pre-allocating address * add a new nativesockets.getAddrString()
* Remove deprecated stuff from stdlib (#14699)Miran2020-06-171-16/+0
| | | | | | | * update to the latest Jester * remove deprecated procs from some stdlib modules * 'criterion' is not maintained anymore and relies on obsolete stuff
* Change `UnpackError` with `UnpackDefect` (#14457)Ivan Bobev2020-05-271-3/+4
| | | | | | | | | | | | | | | | | | * Change `UnpackError` with `UnpackDefect` The deprecation warning for `UnpackError` exception raised by some `inline` procedures in the Nim standard library propagates to the user code. If the user code has a requirement for building without warnings this is a problem for the successful execution of the tests. In order to resolve this, all occurrences of `UnpackError` in the Nim code base are changed to `UnpackDefect`. Only the type alias is retained to not break other people's user code since `UnpackError` is exported type. * Remove the catching of `UnpackDefect` Defect exceptions should not be cached, because they indicate problem in the API usage. The code in `nimblesocket.nim` is rewritten to first check whether there is a value set into the `knownDomain` variable from the `Option` type before usage.
* nativesockets: add missing inheritable pass-throughLeorize2020-05-071-1/+1
|
* Make file descriptors from stdlib non-inheritable by default (#13201)alaviss2020-04-201-20/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * io: make file descriptors non-inheritable by default This prevents file descriptors/handles leakage to child processes that might cause issues like running out of file descriptors, or potential security issues like leaking a file descriptor to a restricted file. While this breaks backward compatibility, I'm rather certain that not many programs (if any) actually make use of this implementation detail. A new API `setInheritable` is provided for the few that actually want to use this functionality. * io: disable inheritance at file creation time for supported platforms Some platforms provide extension to fopen-family of functions to allow for disabling descriptor inheritance atomically during File creation. This guards against possible leaks when a child process is spawned before we managed to disable the file descriptor inheritance (ie. in a multi-threaded program). * net, nativesockets: make sockets non inheritable by default With this commit, sockets will no longer leak to child processes when you don't want it to. Should solves a lot of "address in use" that might occur when your server has just restarted. All APIs that create sockets in these modules now expose a `inheritable` flag that allow users to toggle inheritance for the resulting sockets. An implementation of `setInheritance()` is also provided for SocketHandle. While atomically disabling inheritance at creation time is supported on Windows, it's only implemented by native winsock2, which is too much for now. This support can be implemented in a future patch. * posix: add F_DUPFD_CLOEXEC This command duplicates file descriptor with close-on-exec flag set. Defined in POSIX.1-2008. * ioselectors_kqueue: don't leak file descriptors File descriptors internally used by ioselectors on BSD/OSX are now shielded from leakage. * posix: add O_CLOEXEC This flag allows file descriptors to be open() with close-on-exec flag set atomically. This flag is specified in POSIX.1-2008 * tfdleak: test for selectors leakage Also simplified the test by using handle-type agnostic APIs to test for validity. * ioselectors_epoll: mark all fd created close-on-exec File descriptors from ioselectors should no longer leaks on Linux. * tfdleak: don't check for selector leakage on Windows The getFd proc for ioselectors_select returns a hardcoded -1 * io: add NoInheritFlag at compile time * io: add support for ioctl-based close-on-exec This allows for the flag to be set/unset in one syscall. While the performance gains might be negliable, we have one less failure point to deal with. * tfdleak: add a test for setInheritable * stdlib: add nimInheritHandles to restore old behaviors * memfiles: make file handle not inheritable by default for posix * io: setInheritable now operates on OS file handle On Windows, the native handle is the only thing that's inheritable, thus we can assume that users of this function will already have the handle available to them. This also allows users to pass down file descriptors from memfiles on Windows with ease, should that be desired. With this, nativesockets.setInheritable can be made much simpler. * changelog: clarify * nativesockets: document setInheritable return value * posix_utils: atomically disable fd inheritance for mkstemp
* [backport] run nimpretty on the remaining filesnarimiran2019-09-301-48/+52
|
* tiny style change [refactoring]Andreas Rumpf2019-08-081-1/+1
|
* there is only one style -- my styleAraq2019-07-101-6/+6
|
* make more parts of the stdlib compile with --styleCheck:errorAraq2019-07-101-2/+2
|
* styleCheck: make the compiler and large parts of the stdlib compatible with ↵Araq2019-07-101-9/+9
| | | | --styleCheck:error
* ABI fixes for OSX/BSD; fixes #6860 (#11666)Andreas Rumpf2019-07-061-6/+6
|
* Render deprecated pragmas (#8886)LemonBoy2019-06-031-6/+2
| | | | | | | | | * Render deprecated pragmas * fix the expected html * clean up the documentation regarding deprecations * fix typo * fix system.nim * fix random
* Remove long deprecated stuff (#10332)Miran2019-01-181-63/+0
|
* Fix getAddrInfo, add IPPROTO_ICMPV6 Closes #10198Federico Ceratto2019-01-061-2/+5
|
* Merge pull request #9915 from zevv/asyncnet-unixDominik Picheta2018-12-121-0/+11
|\ | | | | Added basic AF_UNIX support to asyncnet.
| * Added basic AF_UNIX support to asyncnet.Ico Doornekamp2018-12-091-0/+11
| | | | | | | | | | | | | | | | Unfortunately this required some code duplication because the doConnect() from asynccommon.nim only works with addrInfo which does not make sense for AF_UNIX. makeUnixAddr() was moved to nativesocket.nim and exported
* | stdlib: documenation updates, the exception names have been changedAndreas Rumpf2018-10-251-2/+2
|/
* Make getSockDomain work with AF_UNIX socketsLemonBoy2018-09-241-7/+4
| | | | Fixes #9055
* Convert *_family fields to cushortLemonBoy2018-09-191-22/+22
| | | | Fixes #9008
* Haiku support for Nim (#8542)alaviss2018-08-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * posix_other: Haiku now has spawn.h This is added per https://dev.haiku-os.org/ticket/13446 * posix_other: Add Haiku specific Dirent members * cpuinfo: Add an implementation for Haiku * distros: Add basic Haiku support * encodings: update Haiku support * fenv, math: Haiku now provides libm * times: Add Haiku struct members * ansi_c, osalloc: Add Haiku constants * threads: Add Haiku support * testament: Haiku uses LIBRARY_PATH * nim.cfg: Update Haiku support libnetwork should only be linked if network functions are used * threads: Haiku does not support -pthread switch * tworkingdir: Haiku's env is in /bin * posix_other: add SIGKILLTHR for Haiku * sockets: link with libnetwork on Haiku * coro: correct ucontext.h location http://pubs.opengroup.org/onlinepubs/009696699/basedefs/ucontext.h.html * coro: ucontext backend is not available on Haiku Haiku doesn't provide the <ucontext.h> header, as it was removed from POSIX * coro: fix setjmp backend The compiler does not allow statements after a noreturn function * nativesockets: Haiku doesn't support AI_V4MAPPED * system: hostOS can contains "haiku" * os: add support for Haiku's packagefs packagefs is read-only, but there are writable holes to the underlying file system as well * os: update constant for Haiku
* remove deprecated stuff from the stdlib; introduce better deprecation warningsAraq2018-05-051-4/+1
|
* Change type of `Timeval.tv_sec` to `posix.Time` (#7646)Oscar Nihlgård2018-04-181-2/+6
|
* make nativesockets.Hostent.addrlist readable for ipv4 af_inet addresses (see ↵skilchen2018-04-131-2/+18
| | | | issue #7314) (#7327)
* Fixed crash/interface. Added tests.Yuriy Glukhov2018-03-151-1/+1
|
* Fixes #4995. (#7157)Dominik Picheta2018-02-131-2/+22
|
* Implements nativesockets.accept.Dominik Picheta2017-11-241-2/+15
|
* breaking change: arrays of char do not convert to cstring; ptr to array of ↵Andreas Rumpf2017-10-101-6/+8
| | | | char does
* Merge branch 'stringify-array' of https://github.com/krux02/Nim into ↵Andreas Rumpf2017-10-091-2/+2
|\ | | | | | | krux02-stringify-array
| * removed newString proc again, reverted some unnecesary changesArne Döring2017-07-241-2/+2
| |
* | Fix `getPeerAddr()` `getPeerAddr()`: +`sin6_addr` (#6410)wt2017-09-211-2/+2
| |
* | Introduce first class support for Android (#5772)Fredrik Høisæther Rasch2017-08-061-1/+1
|/
* Implement dial, support IPv6 in httpclient (#5763)Ruslan Mustakov2017-05-021-16/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement dial, support IPv6 in httpclient Added ``dial`` procedure to networking modules: ``net``, ``asyncdispatch``, ``asyncnet``. It merges socket creation, address resolution, and connection into single step. When using ``dial``, you don't have to worry about IPv4 vs IPv6 problem. Fixed addrInfo loop in connect to behave properly. Previously it would stop on first non-immediate failure, instead of continuing and trying the remaining addresses. Fixed newAsyncNativeSocket to raise proper error if socket creation fails. Fixes: #3811 * Check domain during connect() only on non-Windows This is how it was in the previous implementation of connect(). * Call 'osLastError' before 'close' in net.dial * Record osLastError before freeAddrInfo in net.dial * Add missing docs for 'dial' proc * Optimize dial to create one FD per domain, add tests And make async IPv6 servers work on Windows. * Add IPv6 test to uri module * Fix getAddrString error handling
* Posix from detect (#5697)Jacek Sieka2017-04-121-6/+6
| | | | | | | | | | * refactor posix.nim * types move to separate files for platform-specifc and generic ("other') * consts move to separate files that get autogenerated by detect.nim * proc's stay where they are for now, though in a second stage might move as well * fix missing when
* Fixes ambiguity introduced by #5390.Dominik Picheta2017-04-091-2/+2
|
* Add gethostname to nativesockets (#5443)Federico Ceratto2017-03-011-0/+16
|
* cleaned up accept-close-race fix #5279Araq2017-02-071-25/+0
|
* Move checkCloseError to nativesocketsRuslan Mustakov2017-02-071-0/+25
|