-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.c
56 lines (52 loc) · 1.38 KB
/
client.c
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
46
47
48
49
50
51
52
53
54
55
56
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<stdbool.h>
#include "tools.h"
int main(){
struct sockaddr_in server;
int sd,msgLength;
char buff[50];
char result;
//connection establishment
sd=socket(AF_INET,SOCK_STREAM,0);
server.sin_family=AF_INET;
//server.sin_addr.s_addr=inet_addr("172.16.81.54"); //other machine
//server.sin_addr.s_addr=INADDR_ANY; //same machine
server.sin_addr.s_addr=inet_addr("127.0.0.1"); //same machine
server.sin_port=htons(8080);
connect(sd,(struct sockaddr *)&server,sizeof(server));
while(1){
printf("\e[1;1H\e[2J");
printf("\n\n\n\t\t\t*************************************\n");
printf("\t\t\t*** WELCOME TO BANKING SYSTEM ***\n");
printf("\t\t\t*************************************\n\n\n");
printf("1. Sign up\n2. Sign in\n3. Exit\n\nchoice:");
//printf("*************************************\n");
int choice;
scanf("%d",&choice);
switch(choice)
{
case 1:
create_mode();
break;
case 2:
chooseOption(sd);
showMenu(sd);
break;
case 3:
write(1,"\n\n\t\tThanks for visiting us\n\t*********Have a nice day*********\n\n\n",sizeof("\n\n\t\tThanks for visiting us\n\t*********Have a nice day*********\n\n\n"));
exit(0);
break;
default:
printf("Please enter valid choice.\n");
break;
}
}
close(sd);
return 0;
}