Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the code for my server is getting a strange error: python3 echoServ.py 10000 Traceback (most recent call last): File /home/susaf/Desktop/echoServ.py, line 42, in csocks, addr

the code for my server is getting a strange error:

python3 echoServ.py 10000 Traceback (most recent call last): File "/home/susaf/Desktop/echoServ.py", line 42, in csocks, addr = sock.accept() ^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 294, in accept fd, addr = self._accept() ^^^^^^^^^^^^^^ BlockingIOError: [Errno 11] Resource temporarily unavailable

is there something wrong with my code?

import socket import struct import sys import statistics

def send_data(sock, data): msg = struct.pack('!iii', data[0], data[1], int(data[2]*100)) sock.sendall(msg)

def recv_data(sock): msg = sock.recv() data = struct.unpack('!i', msg) return (data[0], data[1], data[2] / 100)

#multiple servers list csocks = [] sSocket = []

#number of command line arguments if(len(sys.argv) != 2): print("Usage: python3 Program 01 Server ") exit()

#port from user input port = int(sys.argv[1])

#TCP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#bind socket to port sock.bind(('localhost', port))

#listen for incoming connections sock.listen(5) sock.setblocking(False) sSocket.append(sock)

while True: csocks, addr = sock.accept() print("Connected by", addr) min_value = None max_value = None count = 0 total = 0 while True: data = recv_data(csocks) if data[0] == -1: break print("Received value")

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

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago

Question

3. What are potential solutions?

Answered: 1 week ago