-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.h
More file actions
39 lines (33 loc) · 695 Bytes
/
client.h
File metadata and controls
39 lines (33 loc) · 695 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
39
#ifndef CLIENT_H_
#define CLIENT_H_
#include <iostream>
#include <cstring>
#include <stdexcept>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define BUFFER_SIZE 1024
#define PORT_NUM 5001
class TCPClient
{
private:
int sockfd;
struct sockaddr_in serverAddr;
public:
TCPClient(const char *serverAddress, int port);
~TCPClient()
{
close(sockfd);
}
void connectToServer();
int getClientSocketFd() const;
};
class Communication
{
public:
Communication() {}
void sendMessage(int fd, const char *buffer);
void receiveMessage(int fd, char *buffer);
};
#endif