Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MY PYTHON CODE NEEDS TO PULL A CHUNK OF DATA AND OUTPUT IT, THIS IS WHAT I HAVE SO FAR: IT OUTPUTS THAT IT MAKES

MY PYTHON CODE NEEDS TO PULL A CHUNK OF DATA AND OUTPUT IT, THIS IS WHAT I HAVE SO FAR:

IT OUTPUTS THAT IT MAKES A SUCCESSFUL CONNECTION, JUST KNOW DATA! DUE BY MIDNIGHT PLEASE HELP!

CLIENT.PY

import struct import socket from Assign import Server Server.py f = open('block.dd', 'rb') mbr = bytearray() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) HOST = '' PORT = '' s.bind(('0.0.0.0', 0)) print(s.recv(1024)) try: mbr = f.read(2048) s.send(mbr) finally: f.close() status = mbr[0x1BE] if status == 0x80: print('Status: Active') s.send('Status: Active') ptype = mbr[0x1BE+4] print('Partition type:', ptype) s.send(ptype) addr = struct.unpack(' 

SERVER.PY

import socket import sys HOST = '0.0.0.0' PORT = '0' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print('Socket created') f = open('block.dd', 'rb') mbr = bytearray() try: s.bind(('0.0.0.0', 0)) except socket.error as msg: print('Bind failed. Error code: ' + str(msg[0]) + 'Message') + msg[1] sys.exit() print('Socket bind complete') s.listen(5) print('Socket now listening') while True: c, addr = s.accept() print('Got connection from', + addr) c.send('Thank you for connecting') while 1: print(c.recv(2048)) c.close() 

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

Students also viewed these Databases questions

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago