Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i was able to successfully run both the server and clint code local. I want to run the server code on Amazon Web Services Could9

i was able to successfully run both the server and clint code local. I want to run the server code on Amazon Web Services Could9 IDE and the clint on my local pc. In other words if i log in to aws could 9 from out of town and run the server code the clint code back home can connect to it.

this is the server.py code

import socket

# create the socket # AF_INET == ipv4 # SOCK_STREAM == TCP HEADERSIZE = 10 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((socket.gethostname(), 1235)) #ip and port https://console.aws.amazon.com/cloud9/ide/d727a5cbff9f4ecdabfaa00d2b6b03f5 port 80 s.listen(5) while True: # now our endpoint knows about the OTHER endpoint. clientsocket, address = s.accept() print(f"Connection from {address} has been established.") msg="welcom to the server" msg=f'{len(msg):<{HEADERSIZE}}'+msg clientsocket.send(bytes(msg,"utf-8"))

this is the client.py

import socket import select import errno

HEADERSIZE = 10

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((socket.gethostname(), 1235))

while True: full_msg = '' new_msg = True while True: msg=s.recv(16) if new_msg: print("new data:",msg[:HEADERSIZE]) msglen = int(msg[:HEADERSIZE]) new_msg = False full_msg += msg.decode("utf-8") if len(full_msg)-HEADERSIZE == msglen: print("data recvd") print(full_msg[HEADERSIZE:]) new_msg = True full_msg = '' print(msg)

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago