Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using these two files: --------------------server.py-------------------- import socket last_message = NONE s = socket.socket() print Socket successfully created port = 12345 s.bind(('', port)) print socket binded

Using these two files: --------------------server.py--------------------

import socket

last_message = "NONE"

s = socket.socket()

print "Socket successfully created"

port = 12345

s.bind(('', port))

print "socket binded to %s" %(port)

s.listen(5)

print "socket is listening"

while True:

c, addr = s.accept()

print 'Got connection from', addr

print 'Sending last message'

c.send(last_message)

msg = c.recv(1024)

print 'new message recieved:'

print msg

last_message = msg

c.close() --------------------client.py--------------------

# Import socket module

import socket

# Create a socket object

s = socket.socket()

# Define the port on which you want to connect

port = 12345

msg = raw_input("Message to send: ")

# connect to the server on local computer

s.connect(('127.0.0.1', port))

s.send(msg)

print s.recv(1024)

# close the connection

s.close() Make it so these two files will be able to send messages back and forth to one another in separate terminal sessions. And make a third file, that can *spoof* a message in the conversation. (A third sender acting as one in the two-way conversation).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

Who should attend?

Answered: 1 week ago