TCP/IP client library usage

How to use the TCP/IP client library?

Include and link

Include the main header for the library.

#include <tcp_client/class_tcp.h>

Add to the manifest the dependency.

<depend package="tcp_client"/>

This two steps should be enough to compile and link with the library.

Class declaration

First create the object and initialize it.

tcp_client comm("",1000);

The class constructor will setup the socket but will NOT open it. The first argument of the constructor is the IP of the server and the second the port number to use.
The class can also be used in asynchronous communications by using the following constructor:

tcp_client comm("",1000,true);

The user is responsible for the interception of communication signals (SIGIO) and its handling.

Using the class

Class usage is very simple, the user must only class the desired function to Send() or Receive() data.

char output_message[1024];
char input_message[1024];


strcpy(output_message,"I'm alive");

comm.perr("Could not send message");

printf("Message \"%s\", sent successfully\n",output_message); 

comm.perr("Could not receive message");

printf("Message \"%s\", received\n",input_message); 
 All Classes Files Functions Variables

Author(s): Jorge Almeida
autogenerated on Wed Jul 23 04:34:44 2014