Skip to content

Commit 8a4edf9

Browse files
committed
first commit
0 parents  commit 8a4edf9

3 files changed

+93
-0
lines changed

Project 1- 4344_5344_Spring_2021.pdf

131 KB
Binary file not shown.

client template.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
import socket
3+
from time import *
4+
import sys
5+
import time
6+
7+
8+
HOST=
9+
PORT=
10+
fileName=
11+
12+
13+
14+
clientSocket = socket.socket()
15+
16+
print'Client has been established'
17+
server_add = ()
18+
19+
clientSocket.connect()
20+
# connect the host and port to the socket
21+
send_time = time.time()
22+
clientSocket.send()
23+
24+
25+
data=clientSocket.recv(1024)
26+
recv_time = time.time()
27+
RTT = recv_time - send_time
28+
print'Data received by the client is', data
29+
print'RTT ', RTT
30+
31+
'''Print other vvalues here '''
32+
''' close socket '''

server template.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
# Import socket module
3+
4+
# Import thread module
5+
6+
7+
# Create a TCP server socket
8+
9+
10+
serverSocket = socket.socket()
11+
12+
# Assign a port number
13+
serverPort =
14+
15+
16+
# Bind the socket to server address and server port
17+
18+
serverSocket.bind()
19+
20+
# Listen to at most 5 connection at a time
21+
22+
serverSocket.listen()
23+
24+
# Server should be up and running and listening to the incoming connections
25+
26+
def multi_thread(connectionSocket):
27+
try:
28+
29+
# Extract the path of the requested object from the message
30+
31+
32+
message = connectionSocket.recv(1024).decode('utf-8')
33+
34+
f = open(message,'rb')
35+
36+
# Store the entire contenet of the requested file in a temporary buffer
37+
38+
outputdata = f.read()
39+
40+
41+
# Send the HTTP response header line to the connection socket
42+
43+
44+
# Send the content of the requested file to the connection socket
45+
46+
47+
# Close the socket in case of some issues
48+
connectionSocket.close()
49+
50+
51+
while True:
52+
'''This part is for multi threading'''
53+
print 'Ready to serve'
54+
'''Start the new thread'''
55+
56+
57+
58+
59+
60+
61+

0 commit comments

Comments
 (0)