-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.py
More file actions
39 lines (25 loc) · 916 Bytes
/
Client.py
File metadata and controls
39 lines (25 loc) · 916 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
import socket
import sys
from time import *
# TCP/IP Connection for a new Client server client
clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IP,PORT = sys.argv[1],sys.argv[2] #getting input from termianl
filename = sys.argv[3] #getting file name from the terminal
print 'IP is ', IP
print 'PORT is ', PORT
print 'Filename is ', filename
# Connect to the socket
server_add = (IP,int(PORT))
print 'Connection to :', server_add
clientSocket.connect(server_add) # Connected to the server
print 'Server Connected!'
sent_at = time()
print 'File Request sent at :', sent_at
#sending a filename to the client
clientSocket.send(filename) # Requesting the filename from the server
inputData = clientSocket.recv(1024) # Receving the data from the sever
rec_at = time()
print 'Received at :', rec_at
print 'Time Taken :', rec_at - sent_at
print 'Data received by client is: '
print inputData