-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.c
More file actions
38 lines (32 loc) · 853 Bytes
/
client.c
File metadata and controls
38 lines (32 loc) · 853 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
#include "client_functions.h"
int printOptions(int);
void interface(int);
int get_auth_details(int, int);
void user_interface(int);
void admin_interface();
int main(int argc, char const *argv[])
{
int sock = 0, valread;
struct sockaddr_in serv;
char *hello = "HI from client";
char buffer[1024] = {0};
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("\n Socket creation error \n");
return -1;
}
serv.sin_family = AF_INET;
serv.sin_port = htons(PORT);
if (inet_pton(AF_INET, "127.0.0.1", &serv.sin_addr) <= 0)
{
printf("\nInvalid address/ Address not supported \n");
return -1;
}
if (connect(sock, (struct sockaddr *)&serv, sizeof(serv)) < 0)
{
printf("\nConnection Failed \n");
return -1;
}
interface(sock);
return 0;
}