-
Notifications
You must be signed in to change notification settings - Fork 432
Component Internet
Vexatos edited this page Jul 13, 2014
·
2 revisions
For those that don't like images: the wiki has moved to a new place, http://ocdoc.cil.li/.
This wiki will no longer be updated.
This lists the callbacks made available by the Internet Card. Also see the Internet API for more comfortable access to the HTTP and TCP functionality.
-
internet.isHttpEnabled():boolean
Returns whether HTTP requests are allowed on the server (config setting). -
internet.isTcpEnabled():boolean
Returns whether TCP sockets are allowed on the server (config setting). -
internet.request(url:string[, postData:string]):boolean
Begins an HTTP request to the specified URL with the specified POST data (if any). Responses will be enqueued ashttp_response
signals. Consider using the iterator wrapper in the Internet API instead. -
internet.connect(address:string[, port:number]):number
Opens a new TCP connection. Returns the handle of the connection. The returned handle can be used to interact with the opened socket using the other callbacks. This can error if TCP sockets are not enabled, there are too many open connections or some other I/O error occurs.
Consider using the Internet API to get a buffered stream wrapping the opened socket handle (internet.open
). -
internet.read(handle:number, n:number):string
Tries to read data from the socket stream. Returns the read byte array. Takes the handle returned frominternet.connect
. -
internet.write(handle:number, data:string): number
Tries to write data to the socket stream. Returns the number of bytes written. Takes the handle returned byinternet.connect
. -
internet.close(handle:number)
Closes the socket with the specified handle (obtained frominternet.connect
).