-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtcp.h
More file actions
38 lines (30 loc) · 709 Bytes
/
tcp.h
File metadata and controls
38 lines (30 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
C++ client example using sockets
http://www.binarytides.com/code-a-simple-socket-client-class-in-c/
Modified - GBG 9/2013 - CpSc6120
**/
#ifndef _TCPCLIENT_H_
#define _TCPCLIENT_H_
#include<iostream> //cout
#include<stdio.h> //printf
#include<string.h> //strlen
#include<string> //string
#include<sys/socket.h> //socket
#include<arpa/inet.h> //inet_addr
#include<netdb.h> //hostent
/**
TCP Client class
**/
class tcp_client {
private:
int sock;
std::string address;
int port;
struct sockaddr_in server;
public:
tcp_client();
bool conn(std::string port, int address);
bool send_data(std::string data);
std::string receive(int size=512);
};
#endif