1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/GET_(TCP%2FIP_statement).txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

52 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''GET''' reads unformatted (raw) data from an open TCP/IP connection opened with [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]].
{{PageSyntax}}
''Syntax 1:''
: '''GET''' ''#handle'', , ''b$''
* Reads any available data into variable length string b$ (b$'s length is adjusted to the number of bytes read, so checking EOF is unnecessary) using the handle return value from [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]].
''Syntax 2:''
: '''GET''' ''#handle'', ,''x%''
* Reads an integer. If 2 bytes are available, they are read into x%, if not then nothing is read and [[EOF]](handle) will return -1 (and ''x%'''s value will be undefined) using the handle return value from [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]].
==Communicating using unformatted/raw streamed data==
* Benefit: Communicate with any TCP/IP compatible protocol (eg. FTP, HTTP, web-pages, etc).
* Disadvantage: Streamed data has no 'message length', as such just the program deals with a continuous number of bytes in a row. Some messages get fragmented and parts of messages can (and often do) arrive at different times, due to the very nature of the TCP/IP protocol.
* The position parameter (between the commas) is not used in TCP/IP connections.
* The programmer must cater for these situations manually.
{{PageExamples}}
''Example:''
{{CodeStart}}
{{Cl|PUT|PUT #}}c, , a$ ' sends data
{{Cl|GET|GET #}}o, , b$ ' reads any available data into variable length string b$
{{Cl|GET|GET #}}o, , x% ' if 2 bytes are available, they are read into x%
{{CodeEnd}}
''Explanation:''
* Data could be a string, variable array, user defined [[TYPE]], etc.
* b$'s length is adjusted to the number of bytes read. Checking [[EOF]](o) is unnecessary.
* If 2 bytes are not available for the x% integer then nothing is read and [[EOF]](o) will return -1
===More examples===
* ''See the examples in [[_OPENCLIENT]] or [[Email Demo]].''
{{PageSeeAlso}}
* [[PUT (TCP/IP statement)]]
* [[_OPENCLIENT]], [[_OPENHOST]]
* [[_OPENCONNECTION]], [[GET|GET #]]
* [https://curl.haxx.se/ cURL] (HTTP and FTP file transfer)
{{PageNavigation}}
<