Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

lrt::Network Class Reference

The network manager for libRT. More...

#include <rtnetwork.h>

List of all members.

Public Types

enum  HttpMethod { GET = 0, POST = 1, HEAD = 2 }
 HTTP Request method. Currently supported: GET, POST and HEAD.


Static Public Methods

Socket * create (const String &server, int port)
 creates a client socket
Parameters:
server  Server to connect to
port  Port to connect to on the remote server
Returns:
Zero if error, a Socket object otherwise.


ServerSocket * createServer (int port)
 creates a server socket
Parameters:
port  Port to listen to.
Returns:
Zero if error, a ServerSocket object otherwise.


const Time & getTimeout ()
 Get the maximum waiting duration before the socket read operation is stopped.

void setTimeout (const Time &)
 Set the maximum waiting duration before a socket read operation is cancelled Initially, this is set to 60 seconds to avoid application blocking. You can set the timeout to zero (Time()) to disable timeout entirely.

void splitURL (const String &url, String &proto, String &server, int &port, String &file)
 Splits an URL into protocol, server, port and file. Components that are not given in the original url are set to their default values.

bool httpRequest (const String &url, HttpMethod method, Page &page)
 Performs a HTTP request. More...

bool httpRequest (const String &server, int port, HttpMethod method, const String &file, Page &page)
 Extended form.

String urlEncode (const StringMap< String > &data)
 Encodes a key-value table to an URL encoded form string. Additionally, non-acceptable characters are encoded to xx hex number fomat.

String urlEncode (const String &str)
 Encodes all non-acceptable characters in the given string to xx hex numbers.


Detailed Description

The network manager for libRT.

Has methods for creating sockets.


Member Function Documentation

bool lrt::Network::httpRequest (  const String &    url,
HttpMethod    method,
Page &    page
)  [static]
 

Performs a HTTP request.

If you are performing a POST request, the data in page.text will be transmitted to the server. You should set the page.headers[Content-Type] appropriately before performing the request. Note especially that for sending forms to PHP pages, the default encoding text/plain does not work. You have to create a query string in the same format as for GET requests (see urlEncode()) and use the Content-Type "application/x-www-form-urlencoded".


The documentation for this class was generated from the following files:
This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer