-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.h
More file actions
30 lines (20 loc) · 776 Bytes
/
helpers.h
File metadata and controls
30 lines (20 loc) · 776 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
// Copyright PCom Lab 9
#ifndef _HELPERS_
#define _HELPERS_
#define BUFLEN 4096
#define LINELEN 1000
// shows the current error
void error(const char *msg);
// adds a line to a string message
void compute_message(char *message, const char *line);
// opens a connection with server host_ip on port portno, returns a socket
int open_connection(char *host_ip, int portno, int ip_type, int socket_type, int flag);
// closes a server connection on socket sockfd
void close_connection(int sockfd);
// send a message to a server
void send_to_server(int sockfd, char *message);
// receives and returns the message from a server
char *receive_from_server(int sockfd);
// extracts and returns a JSON from a server response
char *basic_extract_json_response(char *str);
#endif