Commit graph

80 commits

Author SHA1 Message Date
Sönke Ludwig ae6506289a Fix waitForDataEx's return value for an open connection and a zero timeout.
IOMode.once causes the read() to return with IOStatus.wouldBlock immediately, which previously resulted in erroneously reporting WaitForDataStatus.noModeData instead of timeout.

See vibe-d/vibe.d#2483
2020-10-15 13:13:15 +02:00
Geod24 bd8c2c6e90 Use logException consistently and use logDiagnostic
Many places around were re-inventing logException with varying level of success.
In addition, the full error is now printed as a diagnostic instead of debug.
This is more in line with the description of `LogLevel.diagnostic`
("Extended user information (e.g. for more detailed error information)"),
as opposed to the one of `LogLevel.debug_`
("Developer information useful for algorithm debugging").
2020-08-24 05:17:59 +02:00
Steven Dwy 467c6a0996 resolveHost: Check expected address family on returned address
The code as is never checks the requested address family when doing a DNS query,
so resolving an IPv6 only host with AddressFamily.INET would still return an IPv6.
2020-08-21 07:19:39 +02:00
Andrej Mitrovic f2c6cea071 Add optional timeout parameter to resolveHost
This will be useful in e.g. the client,
which uses connection timeouts but does not use
any timeout for resolving the host as of yet.
2020-08-19 13:47:34 +09:00
Geod24 bccd494072 Replace 'body' with 'do' 2020-04-17 01:29:16 +09:00
Sönke Ludwig 73367273b5 Fix behavior of TCPConnection.write when the connection gets closed half-way trough.
Should throw an exception in case of IOMode.all, but actually returned a partial result.
2020-03-18 12:36:08 +01:00
Sönke Ludwig 8e24c4a204 Correct copyright holder.
rejectedsoftware e.K. doesn't exist anymore since mid-2019.
2020-01-27 19:20:52 +01:00
Sönke Ludwig 0d78dfe4a9 Let TCPConnection.leastSize time out according to the readTimeout property.
Fixes #153.
2019-06-16 09:55:00 +02:00
Sönke Ludwig 5393109669 Add TCPConnection.waitForDataEx.
Allows to distinguish between timeout and no more data cases.
2019-06-04 15:20:54 +02:00
Radu Racariu 5e8e75e3e8 Add way to disable port and address reuse 2019-04-17 16:40:04 +03:00
Sönke Ludwig 1ca950867a Fix typo. 2019-04-05 09:47:37 +02:00
Steven Dwy 111478ef41 Fix #109 - TCPConnectionFunction is actually a delegate 2019-02-24 02:55:47 -08:00
WebFreak001 611505c038 remove refsLeft assert
It seems when running in a vibe-d app that the assert fails
Even though I would like there to be a check, closing the vibe.d
app afterwards shows no leaked handles so I think it's fine.
2019-01-22 20:16:38 +01:00
Sönke Ludwig 568cdb112b
Merge pull request #116 from WebFreak001/fix-115
release ref on failing connectTCP
2019-01-19 15:06:39 +01:00
Sönke Ludwig 28260bd612 Use a robust check IP vs. host name check for resolveHost. Fixes #117. 2019-01-16 22:31:14 +01:00
WebFreak001 4d4401c31f Fix assert not compiling in releaseRef 2019-01-09 00:28:27 +01:00
WebFreak001 9d6b34c73a release ref on failing connectTCP
fix #115
2019-01-09 00:18:43 +01:00
Sönke Ludwig 0d3338a16b
Merge pull request #111 from WebFreak001/fix-110
Make waitForData not assert fail on close fix #110
2018-12-20 10:14:08 +01:00
WebFreak001 bc3b319783 Fix potential crash if context is null on closed socket
If the other side closes the connection this might happen
Without this check the following m_context.readBuffer would segfault
2018-12-20 02:20:41 +01:00
WebFreak001 c8ab6ae2f8 Make waitForData not assert fail on close fix #110 2018-12-20 02:10:40 +01:00
Mathias L. Baumann e2834a245b UDP connect wrongly passes port as addr family to resolveHost 2018-12-08 10:14:59 +01:00
Sönke Ludwig 897fee84ea Free resources associated with waitForDataAsync as early as possible.
Instead of letting the GC clean up at an undefined point in time.
2018-09-03 13:45:53 +02:00
Sönke Ludwig 0b638634c9 Fix waitForDataAsync compilation error for callbacks that have scoped destruction. 2018-09-03 12:35:05 +02:00
Boris-Barboris eea57f8914 MonoTime in loopWithTimeout, and other read tweaks.
MonoTime is more robust and does not involve sophisticated timezone
shenanigans, making it better suited for networking operations.
Fixes #39.
This commit also distinguishes read timeout exception as Exception child
ReadTimeoutException, wich is thrown from loopWithTimeout function.
Optimistic read branch for tcp socket improves performance on
granular reads.
2018-03-23 06:45:05 +00:00
Sönke Ludwig e2eef799f8 Fix cancellation of connectTCP in case of early errors.
Certain errors will result in an invalid handle to be returned from eventDriver.sockets.connectStream. In that case it is invalid to call cancelConnect.

Also adds an additional debug log message including a stack trace in case of exceptions thrown from connection handlers.
2018-03-18 12:13:13 +01:00
Sönke Ludwig 2c63aa5c5c Allow destructors to run in foreign threads. Fixes #69.
This change modifies destructors to anticipate that they can be called form a foreign thread if the GC is involved. The actual release of the reference will then happen deferred in the original thread.
2018-03-16 18:06:53 +01:00
Sönke Ludwig eb3620056f Ensure async lambdas are templates to fix LDC linker errors. Fixes #65.
If the lambda is a concrete function, two different versions will end up for it in the final binary on macOS when compiled with LDC. Using argument inference works around that issue.
2018-03-08 14:24:22 +01:00
Sönke Ludwig 57d516a82b
fixup 2018-02-26 19:40:13 +01:00
Sönke Ludwig e33cf567ec
Change callback semantics of waitForDataAsync
Also adds a documentation comment to specify the semantics.
2018-02-26 13:15:24 +01:00
Francesco Mecca 99e2873cc0 assert and stronger condition on TCPConnection.waitForDataAsync
assert and stronger condition on TCPConnection.waitForDataAsync
2018-02-24 21:32:54 +01:00
Francesco Mecca 20e32cf327 added Timer and enum return to TCPConnection.waitForDataAsync 2018-02-23 00:27:04 +00:00
Francesco Mecca 0d6ba62f51 added TCPConnection.waitForDataAsync 2018-02-21 22:17:18 +00:00
Pavel Chebotarev 13e6c2aa41 Fix incorrect return value in TCPConnection.leastSize() 2018-01-27 18:53:16 +03:00
Martin Nowak 30102f9e3a avoid Buffer type which creates a huge __initZ symbol 2018-01-14 04:43:14 +01:00
Sönke Ludwig 2625397f91 Use asyncAwaitAny instead of asyncAwait to work around linker error. 2017-11-25 15:27:17 +01:00
Boris-Barboris 6634cbc645 switch to asyncAwait 2017-11-25 15:27:17 +01:00
Boris-Barboris 55e7866497 implement tcp connect timeout 2017-11-25 15:27:17 +01:00
Sönke Ludwig db449e3cb3 Fix implementation of TCPListener.bindAddress. 2017-09-28 23:52:39 +02:00
Sönke Ludwig 9fe9783443 Convert Waitable from struct to pure template to avoid heap closures.
Also fixes a case where ThreadLocalWaiter.emitSingle overlaps a call to .emit.
2017-09-27 16:41:11 +02:00
Sönke Ludwig 8895f62a49
Fix parameter name. 2017-09-15 15:58:35 +02:00
Sönke Ludwig 333643d48e Add interface_address parameter to UDPConnection.addMembership. 2017-09-15 15:54:59 +02:00
Sönke Ludwig 2d0576a5fe
Implement the UDP multicast support methods. 2017-09-03 18:15:52 +02:00
Sönke Ludwig 7e1d6a7323 Add listenUDP overload taking a NetworkAddress. 2017-09-03 15:54:17 +02:00
Sönke Ludwig f81c9175df
Mention that TCPListenOptions.distribute is deprecated. 2017-07-20 18:48:08 +02:00
Sönke Ludwig d39bbf19c0
Avoid extra exception and allow toString of unspecified NetworkAddress values. 2017-07-19 14:50:20 +02:00
Sönke Ludwig d7b2173cb3 Implement TCPListener.stopListening and fix the vibe.core.net.1726 test.
The test fix follows the fix in the vibe.d repository: rejectedsoftware/vibe.d#f960427e5974c176c58b516647895a2af4ea181b
2017-07-18 11:55:39 +02:00
Sönke Ludwig ca2f9dbe91 Add UDP multicast declarations matching rejectedsoftware/vibe.d#1806.
The actual functionality still needs to be implemented in eventcore.
2017-07-08 10:44:42 +02:00
Sebastian Wilzbach 04b3575c14 Remove deprecated stdc import 2017-07-03 00:39:41 +02:00
Sönke Ludwig 01ed0a43de Adjust for eventcore 0.8.12. 2017-06-27 01:11:50 +02:00
Sönke Ludwig e3f9d07e58
Don't store local/remote address for UDP connections.
Errored out due to the space requirements of UNIX addresses.
2017-03-10 23:00:43 +01:00