-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.txt
42 lines (35 loc) · 1.42 KB
/
client.txt
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
import socket
import os
import time
class generateRequest:
def __init__ (self):
self.timeStamp = 0
self.host = 'localhost'
self.Port = 9090
self. server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self. server_socket.connect((self.host, self.Port))
def connectToServer(self):
while True:
self.size = 4096*100
self. query = self.server_socket.send('Hi, This is client 1\n')
print 'Awaiting reply...'
self. data = self.server_socket.recv(self.size)
print 'Received: ', repr(self.data)
self. userName = raw_input('Enter your Username: ')
self. password = raw_input('Enter your Password: ')
self.userInfo = self.userName + '||||' + self.password
print self.userInfo
self.server_socket.send(self.userInfo)
print self.data
self.wish = raw_input('Do you want to continue [Y/N]: ')
if self.wish.find('Y') < 0:
print 'Enter a valid command. You have to Quit.'
return 0
else:
self.deReg(self.userName)
def deReg(self, userName):
self.toSend = 'Quit ' + str(self.userName)
self.server_socket.send(self.toSend)
if __name__== '__main__':
temp = generateRequest()
temp.connectToServer()