I have a simple socket server which receives request from a client application and then read the csv file and reply with the data from that csv file , on my local machine the below code works fine but when i upload this code to my windows based vps it gives this error :
ServerSocket.listen(5) OSError: [WinError 10022] An invalid argument was supplied
my code :
import socket
import os
from _thread import *
import csv
ServerSocket = socket.socket()
host = '127.0.0.1'
port = 25556
ThreadCount = 0
try:
ServerSocket.bind((host, port))
except socket.error as e:
print(str(e))
print('Waitiing for a Connection..')
ServerSocket.listen(5)
def threaded_client(connection):
while True:
data = connection.recv(2048)
symbolrcvd = data.decode('utf-8')
print (symbolrcvd);
with open('MyRatios.csv') as csvfile:
readval = {row['Symbol']: row for row in csv.DictReader(csvfile)}
data1=readval[symbolrcvd]['Ratio']
reply = data1
if not data:
break
connection.sendall(str.encode(reply))
connection.close()
while True:
Client, address = ServerSocket.accept()
print('Connected to: ' + address[0] + ':' + str(address[1]))
start_new_thread(threaded_client, (Client, ))
ThreadCount += 1
print('Thread Number: ' + str(ThreadCount))
ServerSocket.close()
what could be causing this issue ?