| Concept Framework 2.2 documentation | Contents | Index |
| Name | Version | Deprecated |
| SocketRead | version 1.0 | no |
| number SocketRead(number socket, var buffer, number size,[, bSocketIsUDP=false[, bReceiveExactSize=false]]) |
| socket | a valid and socket descriptor, as returned by SocketCreate |
| buffer | the buffer to fill with retrieved data (any variable, will be allocated by the function) |
| size | the maximum amount of data to read |
| bSocketIsUDP | must be set to true only for UDP sockets |
| bReceiveExactSize | if set to true, packets will be waited, until the buffer will have exactly size octets (default is false). |
| Receives data from a connected socket. |
import standard.net.socket
import standard.lang.cli
import standard.C.io
define DEFAULT_ADDRESS "www.yahoo.com"
define DEFAULT_PORT 80
define MAX_SIZE 0xFFFF
class Main {
function Main() {
// get the command line arguments
var args=CLArg();
var host=DEFAULT_ADDRESS;
var port=DEFAULT_PORT;
if (length args) {
host=args[0];
if (args[1])
port=value args[1];
}
var s=SocketCreate();
echo "Connecting ... ";
if (SocketConnect(s, host, port)==-1) {
echo "Couldn't Connect to $host on port $port: "+SocketError(s)+"\n";
return 0;
}
echo "Connected !\n";
SocketWrite(s, "GET /\r\n\r\n");
// try to read exactly MAX_SIZE bytes (the server will disconnect us)
SocketRead(s, var data, MAX_SIZE, false, true);
WriteFile(data, host+".html");
SocketClose(s);
}
}
|
| Documented by Eduard Suica, generation time: Sun Jan 27 18:15:17 2013 GMT | (c)2013 Devronium Applications |