Using client-server socket programming, implement a multi-threaded server that returns to the client the synonym of a word as stored in a dictionary. The client should prompt the user for a word, reads the word from the screen and sends it to the server and waits for response from the server. Once the client gets the synonym of the word, it should print the word and its synonym on the screen and prompt for another word.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Using client-server socket programming, implement a multi-threaded server that

returns to the client the synonym of a word as stored in a dictionary. The client

should prompt the user for a word, reads the word from the screen and sends it to

the server and waits for response from the server. Once the client gets the synonym

of the word, it should print the word and its synonym on the screen and prompt for

another word. This should continue until the user enters the characters @ to quit.

Example:

>>> python TCPClient.py

Input a word: weak

weak ==> frail

Input a word: fair

fair ==> just

Input a word: @

Notes:

1) A file that contains some words and their synonyms is provided

2) In the server code, read the file to a global python dictionary object

engDict = {} # empty dictionary object

with open('dictionary.txt') as f: # open the file

for line in f:

tok = line.split()

engDict[tok[0]] = tok[1]

print(engDict)

3) Here is a Skelton of the server

[some code here ]

class ServeClient(threading.Thread):

def __init__(self, conn, (ip, port)):

threading.Thread.__init__(self)

self.ip = ip

[add code here ]

def run (self) :

while True:

data =

[ add code here ]

if cmd == '@':

[add code here ]

if engDict.has_key(cmd):

[add code here ]

else:

[add code here ]

[add code here ]

with open('dictionary.txt') as f:

[add code here ]

serverName = socket.gethostname()

serverPort = 12345

serverSocket = [add code here]

serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

[add code here ]

print 'Server ready to recieve '

threads = []

while True:

[ add code here ]

newThread = ServeClient(connectionSocket, addr)

[ add code here ]

for t in threads:

t.join()

What to turn in

Turn in by the due date the two files client.py and server.py

Using client-server socket programming, implement a multi-threaded server that
returns to the client the synonym of a word as stored in a dictionary. The client
should prompt the user for a word, reads the word from the screen and sends it to
the server and waits for response from the server. Once the client gets the synonym
of the word, it should print the word and its synonym on the screen and prompt for
another word. This should continue until the user enters the characters @ to quit.
Example:
> python TCPClient.py
Input a word: weak
weak => frail
Input a word: fair
fair => just
Input a word: @
Notes:
1) A file that contains some words and their synonyms is provided
2) In the server code, read the file to a global python dictionary object
engDict = {} # empty dictionary object
with open('dictionary.txt') as f:
for line in f:
tok = line.split()
engDict[tok[@]] = tok(1]
print(engDict)
# open the file
3) Here is a Skelton of the server
[some code here )
class Serveclient(threading. Thread):
def _init_(self, conn, (ip, port)):
threading. Thread._init_(self)
self. ip - ip
[add code here ]
def run (self) :
while True:
data =
[ add code here ]
Transcribed Image Text:Using client-server socket programming, implement a multi-threaded server that returns to the client the synonym of a word as stored in a dictionary. The client should prompt the user for a word, reads the word from the screen and sends it to the server and waits for response from the server. Once the client gets the synonym of the word, it should print the word and its synonym on the screen and prompt for another word. This should continue until the user enters the characters @ to quit. Example: > python TCPClient.py Input a word: weak weak => frail Input a word: fair fair => just Input a word: @ Notes: 1) A file that contains some words and their synonyms is provided 2) In the server code, read the file to a global python dictionary object engDict = {} # empty dictionary object with open('dictionary.txt') as f: for line in f: tok = line.split() engDict[tok[@]] = tok(1] print(engDict) # open the file 3) Here is a Skelton of the server [some code here ) class Serveclient(threading. Thread): def _init_(self, conn, (ip, port)): threading. Thread._init_(self) self. ip - ip [add code here ] def run (self) : while True: data = [ add code here ]
if cmd == 'e':
[add code here )
if engDict.has_key(cmd):
[add code here )
else:
[add code here
[add code here )
with open('dictionary.txt') as f:
fadd code here 1
serverName = socket. gethostname ()
serverPort = 12345
serverSocket = [add code here
serverSocket.setsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[add code here )
print 'Server ready to recieve
threads - [)
while True:
[ add code here )
newThread = Serveclient(connectionSocket, addr)
[ add code here ]
for t in threads:
t.join()
What to turn in
Turn in by the due date the two files client.py and server.py
Transcribed Image Text:if cmd == 'e': [add code here ) if engDict.has_key(cmd): [add code here ) else: [add code here [add code here ) with open('dictionary.txt') as f: fadd code here 1 serverName = socket. gethostname () serverPort = 12345 serverSocket = [add code here serverSocket.setsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) [add code here ) print 'Server ready to recieve threads - [) while True: [ add code here ) newThread = Serveclient(connectionSocket, addr) [ add code here ] for t in threads: t.join() What to turn in Turn in by the due date the two files client.py and server.py
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY