Question: I have having a problem with my output. This is my client side code: import socket # Import socket module import struct s = socket.socket()

I have having a problem with my output.

This is my client side code:

import socket # Import socket module import struct s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 12345 # Reserve a port for your service. s.connect((host, port)) print(s.recv(1024)) # open the master boot record file called block.dd and save into an array f = open("block.dd", "rb") mbr = bytearray() # this opens the array and closes the file when done try: mbr = f.read(2048) s.send(mbr) finally: f.close() # this loads the content of the first partition entry at address 1BE (hex) # looks for the status type and checks to see if it is active or not status = mbr[0x1BE] class Status(object): pass if status == 0x80: print("Status: Active") s.sendall(b'Status: Active') else: print("Status: Not active") s.sendall(b"Status: Not Active") # this looks at the partition type (1 byte located at the address 1BE + 4) and prints it out ptype = mbr[0x1BE + 4] print("Partition type: ", ptype) s.send(b'ptype') # this looks at the address of the first sector in the partition (1BE + 8) and prints it out addr = struct.unpack(" 

and client side output:

I have having a problem with my output. This is my client

This is my server side code:

import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 12345 # Reserve a port for your service. s.bind((host, port)) # Bind to the port s.listen(5) # Now wait for client connection. while True: c, addr = s.accept() # Establish connection with client. print('Got connection from', addr) c.send(b'Thank you for connecting') while 1: print(c.recv(2048)) c.close() # Close the connection exit(-1)

The problem lies with my server output, in the window, instead of printing the necessary information, it keeps printing b' ' nonstop until I stop the program run myself. The server is suppose to listen for the chunk of data and then print out the status of the drive, the partition type, and the starting address of the partition as an integer. I'm not sure what I'm doing wrong or what I'm missing.

server x client X b'Thank you for connecting' Status: Active Partition type: 131 Address of the first sector in the partition: 2048 Process finished with exit code 0

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!