-
Notifications
You must be signed in to change notification settings - Fork 1
/
client1.py
113 lines (73 loc) · 2.67 KB
/
client1.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Python TCP Client A
import socket
host = socket.gethostname()
port = 2206
BUFFER_SIZE = 2000
print "\n"
print "........Welcome to the Bus Resrvation......"
print "\n"
tcpClientA = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpClientA.connect((host, port))
MESSAGE = raw_input("1. Reservation \n 2. Cancellation \n")
tcpClientA.send(MESSAGE)
if MESSAGE == '1':
MESSAGE = raw_input("Enter the date:(dd-mm)")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Enter the phone-no:")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Select the Type of the Bus :\n 1. SLEEPER \n 2. SEMI-SLEEPER \n 3. SEATER \n")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Select the AC PROVISION :\n 1. AC \n 2. NON-AC \n")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Enter the source:\n")
MESSAGE = MESSAGE + ' '+raw_input("Enter the destination:\n")
print MESSAGE
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print data,"\n" #printing the buses between destinations
data=tcpClientA.recv(2048)
print "The fare for this Trip is:",data,"\n" #printing the buses between destinations
MESSAGE = raw_input("Enter the BUS NO:\n")
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print data,"\n" #printing the seats between destinations
MESSAGE = raw_input("Enter the SEAT NO:\n")
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print data,"\n"#updated printing the seats between destinations
MESSAGE = raw_input("EVERYTHING DONE?:\n")
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print data,"\n"
elif MESSAGE == '2':
MESSAGE = raw_input("Enter the date:(dd-mm)")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Select the Type of the Bus :\n 1. SLEEPER \n 2. SEMI-SLEEPER \n 3. SEATER \n")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Select the AC PROVISION :\n 1. AC \n 2. NON-AC \n")
tcpClientA.send(MESSAGE)
MESSAGE = raw_input("Enter the source:\n")
MESSAGE = MESSAGE + ' '+raw_input("Enter the destination:\n")
print MESSAGE
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print data,"\n" #printing the buses between destinations
MESSAGE = raw_input("Enter the BUS NO:\n")
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print data,"\n" #printing the seats between destinations
MESSAGE = raw_input("Enter the SEAT NO:\n")
tcpClientA.send(MESSAGE)
data=tcpClientA.recv(2048)
print "The return fare for this Trip is:",data,"\n"
#data=tcpClientA.recv(2048)
#print data,"\n"
'''
while MESSAGE != '0':
print("Entered\n")
tcpClientA.send(MESSAGE) #echo
data= tcpClientA.recv(BUFFER_SIZE)
print (data)
MESSAGE = raw_input("1. Show list \n 2. Exit \n Enter your choice: ")
'''
tcpClientA.close()