int NetSend(char *url, int(*callback)(int event, char *response, int length));

 

Sends a network request to the specified URL.  The response will be handled by the callback provided.

 

Return Value

 

Returns value not used.

 

Parameters

 

url

The URL to which to send the request.  Data to be sent to the server goes on the URL after a question mark symbol, with name / value pairs separated by ampersands, e.g. http://www.somesite.com/getdata?name=bob&age=35".  In  the example, you would be sending a name value of "bob" and an age value of "35" to the server for processing by "getdata".

 

callback

The function that will receive the response from the server.

 

Callback parameters:

 

event

Indicates the result of the request.  A value of zero indicates the request failed.  A value of one indicates the request was successful.

 

response

Contains a character buffer that is the response from the server.

 

length

Indicates the length of the response buffer.

 

Remarks

 

NetSend() allows you to send a request to a server and provide a callback to receive the response from the server.

 

Availability

 

Available in DragonFireSDK 1.3 and later.

 

Example

 

#include "DragonFireSDK.h"

 

int MyFont;

int MyText;

 

int OnResponse(int event, char *response, int length)

{

  // Display as much of the server response as possible.

  TextSetText(MyText, response);

  return event;

}

 

void AppMain()

{

  // Set LandscapeMode() so we can see as much data as possible.

  LandscapeMode();

  // Request weather data from google.com for my city.

  NetSend("http://www.google.com/ig/api?weather=dallas,tx", OnResponse);

  // Set up a font and a text to display the data.

  MyFont = FontAdd("Helvetica", "Regular", 12, 0x00FF00);

  MyText = TextAdd(0, 0, "Response", MyFont);

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

 

}