Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!