Skip to content

Commit ee95d0e

Browse files
SOCKFLUSH and docs
1 parent c84e463 commit ee95d0e

File tree

444 files changed

+2871
-1946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

444 files changed

+2871
-1946
lines changed

docpages/basic-language-reference/functions/integer/02_INDEX.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
- \subpage SGN
5151
- \subpage SHL
5252
- \subpage SHR
53+
- \subpage SOCKACCEPT
54+
- \subpage SOCKLISTEN
5355
- \subpage SOCKSTATUS
5456
- \subpage TERMHEIGHT
5557
- \subpage TERMWIDTH
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
\page SOCKACCEPT SOCKACCEPT Function
2+
3+
```basic
4+
client = SOCKACCEPT(server)
5+
```
6+
7+
Removes and returns the next **established** connection from the listening socket’s pending queue. Returns a non-negative file descriptor on success, or `-1` if no connection is ready (or on error).
8+
9+
@note `SOCKACCEPT` is **non-blocking**: it returns immediately. If there are no connections to accept, it will return `-1`.
10+
11+
---
12+
13+
### How to use it
14+
15+
* `server` is the file descriptor returned by `SOCKLISTEN(ip$, port, backlog)`.
16+
* Call repeatedly in your main loop to accept clients as they become ready.
17+
* Use the returned `client` descriptor with `SOCKWRITE`, `SOCKREAD`, `INSOCKET$`, and `SOCKCLOSE`.
18+
* The pending queue is FIFO; only the head is checked each call.
19+
20+
---
21+
22+
### Examples
23+
24+
```basic
25+
REM Minimal accept loop
26+
server = SOCKLISTEN(NETINFO$("ip"), 2000, 5)
27+
IF server < 0 THEN PRINT "Listen failed": END
28+
PRINT "Listening on port 2000"
29+
30+
REPEAT
31+
client = SOCKACCEPT(server)
32+
IF client >= 0 THEN
33+
SOCKWRITE client, "HELLO!" + CHR$(13) + CHR$(10)
34+
SOCKCLOSE client
35+
END IF
36+
UNTIL INKEY$ <> ""
37+
38+
SOCKCLOSE server
39+
```
40+
41+
---
42+
43+
### Notes
44+
45+
* Returns `-1` when no established connection is available; try again later.
46+
* Each successful call returns a **new** client descriptor; the server remains listening.
47+
48+
**See also:**
49+
\ref SOCKLISTEN "SOCKLISTEN" · \ref SOCKWRITE "SOCKWRITE" · \ref SOCKREAD "SOCKREAD" · \ref INSOCKET\$ "INSOCKET\$" · \ref SOCKSTATUS "SOCKSTATUS" · \ref SOCKCLOSE "SOCKCLOSE" · \ref NETINFO\$ "NETINFO\$"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
\page SOCKLISTEN SOCKLISTEN Function
2+
3+
```basic
4+
FD = SOCKLISTEN(ip$, port, backlog)
5+
```
6+
7+
Creates a **listening TCP socket** bound to `ip$:port` and starts queueing incoming connections (up to `backlog`). Returns a non-negative file descriptor on success, or `-1` on failure.
8+
9+
---
10+
11+
### How to use it
12+
13+
* `ip$` is a dotted-quad string (e.g. `"10.0.2.15"`). Use `NETINFO$("ip")` for the local address.
14+
* `port` is the local TCP port to listen on.
15+
* `backlog` is the maximum number of pending (not yet accepted) connections to queue.
16+
* Accept connections with `SOCKACCEPT(FD)`; write with `SOCKWRITE`, read with `SOCKREAD`/`INSOCKET$`, and close with `SOCKCLOSE`.
17+
18+
---
19+
20+
### Examples
21+
22+
```basic
23+
REM Listen and handle one connection
24+
srv = SOCKLISTEN(NETINFO$("ip"), 2000, 5)
25+
PRINT "Socket server listening on port 2000"
26+
REPEAT
27+
cli = SOCKACCEPT(srv)
28+
IF cli >= 0 THEN
29+
SOCKWRITE cli, "HELLORLD!" + CHR$(10) + CHR$(13)
30+
SOCKFLUSH cli
31+
SOCKCLOSE cli
32+
ENDIF
33+
UNTIL INKEY$ <> ""
34+
SOCKCLOSE srv
35+
```
36+
37+
---
38+
39+
### Notes
40+
41+
* Binding to `"0.0.0.0"` (if supported) listens on all local interfaces.
42+
* `SOCKACCEPT` returns a new FD for each established connection; call repeatedly to drain the queue.
43+
44+
**See also:**
45+
\ref SOCKACCEPT "SOCKACCEPT" · \ref SOCKWRITE "SOCKWRITE" · \ref SOCKREAD "SOCKREAD" · \ref INSOCKET\$ "INSOCKET\$" · \ref SOCKCLOSE "SOCKCLOSE" · \ref NETINFO\$ "NETINFO\$"

docpages/basic-language-reference/keywords/00_INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Example: `mystr$`
115115
- \subpage SETVARS
116116
- \subpage SLEEP
117117
- \subpage SOCKCLOSE
118+
- \subpage SOCKFLUSH
118119
- \subpage SOCKREAD
119120
- \subpage SOCKWRITE
120121
- \subpage SPRITEFREE
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
\page SOCKFLUSH SOCKFLUSH Keyword
2+
3+
```basic
4+
SOCKFLUSH integer-variable
5+
```
6+
7+
Blocks until any **pending outbound data** for the given TCP socket has been **flushed from the BASIC send buffer** to the TCP stack.
8+
Use after \ref SOCKWRITE "SOCKWRITE" when you need to ensure queued bytes have been handed off before proceeding (e.g. before closing the socket).
9+
10+
@note This waits for the **local send buffer to empty**; it does **not** wait for peer acknowledgements.
11+
12+
---
13+
14+
### How to use it
15+
16+
* `integer-variable` must contain a socket handle returned by \ref CONNECT "CONNECT" or \ref SOCKACCEPT "SOCKACCEPT".
17+
* The statement **yields** like \ref SOCKREAD "SOCKREAD": your program pauses and resumes automatically when the condition is met.
18+
* Typical use is `SOCKWRITE``SOCKFLUSH``SOCKCLOSE`.
19+
20+
@note Press `CTRL+ESC` at any time to **cancel** waiting.
21+
@note Without an error handler, the program **terminates** on errors; with `ON ERROR`, control passes to your handler.
22+
23+
---
24+
25+
### Examples
26+
27+
**Send a line, flush, then close**
28+
29+
```basic
30+
server = SOCKLISTEN(NETINFO$("ip"), 2000, 5)
31+
client = SOCKACCEPT(server)
32+
IF client >= 0 THEN
33+
SOCKWRITE client, "HELLORLD!" + CHR$(13) + CHR$(10)
34+
SOCKFLUSH client
35+
SOCKCLOSE client
36+
END IF
37+
SOCKCLOSE server
38+
```
39+
40+
**Ensure data is flushed before reusing variables**
41+
42+
```basic
43+
CONNECT s, "93.184.216.34", 80
44+
SOCKWRITE s, "HEAD / HTTP/1.0" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
45+
SOCKFLUSH s
46+
SOCKCLOSE s
47+
```
48+
49+
---
50+
51+
### Notes
52+
53+
* If the socket has no pending data, `SOCKFLUSH` returns immediately.
54+
* If the connection is no longer valid (e.g. already closed), `SOCKFLUSH` returns without waiting.
55+
* Use \ref SOCKSTATUS "SOCKSTATUS" to query whether a socket is connected.
56+
57+
**See also:**
58+
\ref SOCKWRITE "SOCKWRITE" ·
59+
\ref SOCKREAD "SOCKREAD" ·
60+
\ref SOCKCLOSE "SOCKCLOSE" ·
61+
\ref CONNECT "CONNECT" ·
62+
\ref SOCKACCEPT "SOCKACCEPT" ·
63+
\ref SOCKLISTEN "SOCKLISTEN"

docs/ABS.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
9999
<ul>
100100
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a class="el" href="builtin-functions.html">Built-In Functions</a></li><li class="navelem"><a class="el" href="int-funcs.html">Integer Functions</a></li>
101-
<li class="footer">Generated on Thu Sep 11 2025 09:01:30 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
101+
<li class="footer">Generated on Fri Sep 12 2025 15:09:16 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
102102
</ul>
103103
</div>
104104
</body>

docs/ACS.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
100100
<ul>
101101
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a class="el" href="builtin-functions.html">Built-In Functions</a></li><li class="navelem"><a class="el" href="real-funcs.html">Real Functions</a></li>
102-
<li class="footer">Generated on Thu Sep 11 2025 09:01:30 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
102+
<li class="footer">Generated on Fri Sep 12 2025 15:09:16 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
103103
</ul>
104104
</div>
105105
</body>

docs/ASC.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
9999
<ul>
100100
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a class="el" href="builtin-functions.html">Built-In Functions</a></li><li class="navelem"><a class="el" href="int-funcs.html">Integer Functions</a></li>
101-
<li class="footer">Generated on Thu Sep 11 2025 09:01:30 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
101+
<li class="footer">Generated on Fri Sep 12 2025 15:09:16 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
102102
</ul>
103103
</div>
104104
</body>

docs/ASN.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
100100
<ul>
101101
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a class="el" href="builtin-functions.html">Built-In Functions</a></li><li class="navelem"><a class="el" href="real-funcs.html">Real Functions</a></li>
102-
<li class="footer">Generated on Thu Sep 11 2025 09:01:30 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
102+
<li class="footer">Generated on Fri Sep 12 2025 15:09:16 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
103103
</ul>
104104
</div>
105105
</body>

docs/ATAN.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
100100
<ul>
101101
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a class="el" href="builtin-functions.html">Built-In Functions</a></li><li class="navelem"><a class="el" href="real-funcs.html">Real Functions</a></li>
102-
<li class="footer">Generated on Thu Sep 11 2025 09:01:30 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
102+
<li class="footer">Generated on Fri Sep 12 2025 15:09:16 for Retro Rocket OS by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
103103
</ul>
104104
</div>
105105
</body>

0 commit comments

Comments
 (0)