diff --git a/AMOSPro_BSDSocket.Lib b/AMOSPro_BSDSocket.Lib index 74d9ba1..baf6abe 100644 Binary files a/AMOSPro_BSDSocket.Lib and b/AMOSPro_BSDSocket.Lib differ diff --git a/API.md b/API.md index 7c1e5ef..4f6d5d3 100644 --- a/API.md +++ b/API.md @@ -123,9 +123,11 @@ a remote socket to send you data. ##### Returns -* 0 on timeout -* -1,-2 on error -* 1 on success +* 0 on timeout. +* -1 on error. Use `Socket Errno` for more detail. +* -3 on the socket being sorta-ready. This isn't a connection timeout, + so check again. +* 1 on success. #### RESULT=Socket Async Wait Writing(Socket, Wait_ms) @@ -135,9 +137,11 @@ has been completed. ##### Returns -* 0 on timeout -* -1,-2 on error -* 1 on success +* 0 on timeout. +* -1 on error. Use `Socket Errno` for more detail. +* -3 on the socket being sorta-ready. This isn't a connection timeout, + so check again. +* 1 on success. #### RESULT=Socket Set Timeout(Socket, Wait_ms) diff --git a/README.md b/README.md index e20e8ff..26a5b90 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,11 @@ Doing something cool with the extension? most system-friendly way of doing this. * MiamiDX can be fiddly, at least it is on my MiSTer set up. If Internet connectivity is not working, try re-connecting to the network. +* If using Roadshow, `bsdsocket.library` will always be available, so + you can't use its presence or lack thereof to test if Internet is available. + You'll have to use a combination of DNS lookups and/or connection + timeouts using `Socket Async Wait Writing` to determine if the Internet + is available. ## Versioning diff --git a/src/BSDSocket.s b/src/BSDSocket.s index c836974..d92fac8 100644 --- a/src/BSDSocket.s +++ b/src/BSDSocket.s @@ -1576,6 +1576,7 @@ _DoSocketLibraryClose_Skip: ; ; @return ; 1 on success +; -1 on error, check Socket Errno ; -2 on library not open ; -3 on not interesting yet ; 0 on timeout @@ -1627,8 +1628,13 @@ _SocketWaitAsyncWriting_LibraryOpen: MOVE.L BSDSocketBase-MB(A4),A6 CALLLIB WaitSelect - TST.L D0 ; timeout, pass through - BPL _SocketWaitAsyncWriting_Done + ; returns: + ; * 0 on timeout + ; * >0 on socket was seen + ; * -1 on error + TST.L D0 + BEQ _SocketWaitAsyncWriting_Timeout + BMI _SocketWaitAsyncWriting_Error MOVE.L (SP)+,D0 ; D0 contains socket again Dload A4 @@ -1669,6 +1675,7 @@ _SocketWaitAsyncWriting_CheckSockopt: TST.L D0 BEQ _SocketWaitAsyncWriting_Ready + ; still not ready MOVEM.L (SP)+,A3-A4 MOVE.L #-3,D3 @@ -1682,11 +1689,20 @@ _SocketWaitAsyncWriting_Ready: RestoreStackFunction Ret_Int -_SocketWaitAsyncWriting_Done: +_SocketWaitAsyncWriting_Error: MOVE.L (SP)+,D1 MOVEM.L (SP)+,A3-A4 - MOVE.L D0,D3 + MOVE.L #-1,D3 + + RestoreStackFunction + Ret_Int + +_SocketWaitAsyncWriting_Timeout: + MOVE.L (SP)+,D1 + MOVEM.L (SP)+,A3-A4 + + MOVEQ #0,D3 RestoreStackFunction Ret_Int