http_proxy(STRING* proxy,var port)

Sets a http proxy server for the connection to the internet. If no proxy is used, this function needs not to be called.

http_sendpost(STRING* url, STRING* data)

Sends http data with the "post" methode to a web server and returns a httpID. With this httpID the transfer can be controlled with functions like http_status. If no data has to be sent, NULL can be passed for the data string. After the post is finished, the httpID has to be freed with http_free.

http_status(var httpid)

Returns information about a http post:

2 connection problem
1 data was received
0 waiting for data from the server
-1 invalid httpid

http_result(var httpid, STRING* result)

Stores the received data of a http post in the result string and returns the length of the received data.

http_free(var httpid)

Frees the httpID of a http post and stops the transfer. Must be called after each http post.

Parameters:

proxy - proxy server (example: "proxy-host.com"), STRING* or char*.
port - port of the proxy servers (example: 8080).
url - url of the web server (example: "http://www.testserver.com/svlist.php"), STRING* or char*
data - string containing the data to be sent (example: "svname=gameserver&players=16&pw=yes"), STRING*, char*, or NULL.
result - STRING* to receive the result data of the http post oeration.
httpid - httpID of the post, returned by http_post().

Remarks:

Version:

 P  LC

Example:

#include <acknex.h>
#include <default.c>
#include <acknet.h>

STRING* ip_str = "                   ";

// start the script "ip.php" on a remote server, and return the caller's IP address
function main()
{
   var id = http_sendpost("http://coniserver.net/scratch/ip.php","");
   while (!http_status(id)) 
     wait(1);//wait for the server to reply
   if (http_status(id) == 1) { //transfer successful?
     http_result(id,ip_str);   //get the replied IP
     printf(_chr(ip_str));
  } else
     error("Error during transfer!");
  http_free(id); //always cleanup the httpid!
  sys_exit(NULL);
}

ip.php:
<?php
echo "Your IP address: " . $_SERVER['REMOTE_ADDR'];
?>

See also:

ftp functions

► latest version online