class_tcp.h
Go to the documentation of this file.
1 // This file is part of the tcp/ip client library.
2 //
3 // Copyright (C) 2011 LAR - Laboratory for Automation and Robotics, ATLAS Project
4 // Department of Mechanical Engineering
5 // University of Aveiro
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2.1
10 // of the License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 // 02110-1301, USA.
21 
26 #ifndef _CLASS_TCP_H_
27 #define _CLASS_TCP_H_
28 
29 //System Includes
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <unistd.h>
37 #include <fcntl.h>
38 #include <errno.h>
39 #include <iostream>
40 
41 using namespace std;
42 
47 {
48 
49  public:
60  tcp_client(const char*ip,int port,bool async_comm=false);
61 
67  ~tcp_client();
68 
75  int Connect(void);
76 
83  int Disconnect(void);
84 
93  int Send(char*data,int size);
94 
107  int Receive(char*data,int size,bool peek=false,int*number=NULL,int flags=0);
108 
117  int perr(const char*text);
118 
125  int GetSocket();
126 
128  int err;
129 
131  char err_msg[1024];
132 
134  bool connected;
135  private:
136 
138  int sock;
139 
141  struct sockaddr_in server;
142 
144  int ret;
145 
147  bool async;
148 };
149 
150 #endif
151 
int err
Last error code.
Definition: class_tcp.h:128
bool connected
Status of the connection.
Definition: class_tcp.h:134
bool async
Asynchronous comm.
Definition: class_tcp.h:147
int sock
Socket identification.
Definition: class_tcp.h:138
int ret
Return value for functions.
Definition: class_tcp.h:144
This class implements the TCP/IP client communication.
Definition: class_tcp.h:46


tcp_client
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:53