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

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!