-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.h
45 lines (37 loc) · 1.06 KB
/
server.h
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
40
41
42
43
44
45
#ifndef _SERVER_H
#define _SERVER_H
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
typedef struct server {
char myIp[30];
char myPort[10];
int myKey;
char nextIp[30];
char nextPort[10];
int nextKey;
char doubleNextIp[30];
char doubleNextPort[10];
int doubleNextKey;
int prevConnFD; // Holds the TCP connection to previous server
int nextConnFD; // Holds the TCP connection to next server
}Server;
typedef struct udpData {
struct addrinfo *res;
int fd;
}UdpData;
void createServer(Server*, int);
int connectToNextServer(Server*);
void serverIsEntering(char[128], int *, Server*);
void printServerData(Server*);
void copyDoubleToNext(Server *);
int distance(int, int);
int connectToGivenServer(char[30], char[10]);
UdpData* connectToUdpServer(char ip[30], char port[10]);
void startKeySearch(Server *, int, int, struct sockaddr*, socklen_t, int, int *);
void copyNextToDouble(Server *server);
void copySelfToDouble(Server *server);
void cleanServer(Server * server);
void tcpWrite(int, char *);
int tpcRead(int, char *);
#endif