This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
api:internet [2024/09/23 15:14] alekcwins fix english message about unsuport global ports |
api:internet [2024/09/24 23:48] (current) forecaster |
||
---|---|---|---|
Line 1: | Line 1: | ||
Internet API | Internet API | ||
========== | ========== | ||
- | This library wraps functionality of Internet cards. Also see the [[component:internet|Internet Component]] for more low level functionality (such as querying availability of HTTP and TCP functionality). | + | This library wraps functionality of Internet cards. Also see the [[component:internet|Internet Component]] for more low level functionality (such as querying availability of HTTP and TCP functionality). |
+ | |||
+ | **NOTE**: It is not possible to create a listening interface on a port. OC can only connect directly to a server to send and receive messages. | ||
- `internet.request(url: string[, data: string or table[, headers: table[, method: string]]]): function` | - `internet.request(url: string[, data: string or table[, headers: table[, method: string]]]): function` | ||
Line 21: | Line 23: | ||
Opens a buffered socket stream to the specified address. The stream can be read from and written from, using `s:read` and `s:write` - in general it can be treated much like files opened using `io.open`. It may often be desirable to set the buffer's read timeout using `s:setTimeout(seconds)`, to avoid it blocking indefinitely. | Opens a buffered socket stream to the specified address. The stream can be read from and written from, using `s:read` and `s:write` - in general it can be treated much like files opened using `io.open`. It may often be desirable to set the buffer's read timeout using `s:setTimeout(seconds)`, to avoid it blocking indefinitely. | ||
The read method on the returned buffer is *blocking*. Read will wait until some data is available to be read and return that. | The read method on the returned buffer is *blocking*. Read will wait until some data is available to be read and return that. | ||
- | | ||
- | | ||
- | :!: NOTE: `internet.socket and internet.open` - **listening to global ports is not supported**, that is, creating a full-fledged TCP server **for external** connections. | ||
Example usage: | Example usage: |