• Register
0 votes
2.1k views

Problem :

I have looked for solution for literally hours but no luck so I am asking it here.

I am trying to build the chat server using the python's socket module. But when I run the server after my client connects to it and also the server connects, I face following exception:

[WinError 10038] An operation was attempted on something that is not a socket

I have tried to build a drastically reduced server and it works where current server does not. This exception has confused me as it is popping up nearly the line for line.

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Allow me to explain the couple of things to you:

·    At the server side: Generally you will create a socket, bind it, and listen for the connections.

·    At the client side: Generally you will create a socket and then you will try to connect to the server.

I think the server side is fine in your case but when it comes to the client side you need not have following line:

s.bind(("127.0.0.1",port))

You should update your code like following example:

ip = '127.0.0.1'

port = 1234

sc.connect((ip, port))

sc.send("hello".encode("utf-8"))

while True:

 sc.send(input().encode("utf-8"))

Also please make sure that all your indentations are correct and you are closing your sockets correctly as this is the reason why you are facing this error.

9 7 4
38,600 points

Related questions

0 votes
1 answer 58 views
58 views
Problem : I have my web application which is throwing the below error while running in IE: “Illegal operation attempted on a registry key that has been marked for deletion” It works really fine in my Chrome but unfortunately gives the above error in production ... information on my error. And it confuses me as why this is only occurring when trying to use the IE. Any pointers?
asked Jan 6, 2020 alecxe 7.5k points
0 votes
1 answer 10 views
10 views
Problem: I am trying to call a python file "hello.py" from within the python interpreter with subprocess. But I am unable to resolve this error: OSError: [WinError 193] %1 is not a valid Win32 application Also is there any alternate way to "call a python script with arguments" other than using subprocess? Thanks in advance.
asked Apr 2 ummesalma 25.2k points
0 votes
1 answer 2 views
2 views
Problem: Can anyone tell me the solution of this problem? An operation on a socket could not be performed
asked Apr 7 Ifra 24.4k points
1 vote
1 answer 62 views
62 views
Problem: I am loading a dll in python using following code: if os.path.exists(dll_path): my_dll = ctypes.cdll.LoadLibrary(dll_path) But I am continuously getting the following error WindowsError: [Error 126] The specified module could not be found oserror: [winerror 126] the specified module could not be found
asked Feb 24 Sofia Castro 4.2k points
0 votes
1 answer 4 views
4 views
Problem: I am creating a program using python by importing moviepy library, but getting the following error: OSError: [WinError 6] The handle is invalid” in VideoFileClip function
asked Apr 2 ummesalma 25.2k points
0 votes
1 answer 2 views
2 views
Problem: What are my options for resolving this problem? illegal operation attempted on a registry key
asked Apr 7 rakib1 51.5k points
0 votes
1 answer 5 views
5 views
Problem: i need some help about this problem please help? attempted textbuffer edit operation while another edit is in progress
asked Mar 26 Rohit kr 16.2k points
0 votes
2 answers 93 views
93 views
Problem : I am new to Windows 8 OS. I am facing the error while trying to install the IIS manager from the "Turn on off windows features" on my windows 8 machine. I have already installed all the updates on my machine and also rebooted my machine and after ... install the IIS manager. The error is as follows "The function attempted to use a name that is reserved for use by another transaction".
asked Feb 17, 2020 mphil 2.3k points
0 votes
1 answer 191 views
191 views
Problem : My Windows Server 2012 VM was working without any issues, I just restarted it. After restarted my vm, I changed some of the settings and also attached the dvd drive it would boot up again. But now it gives below error: “Failed - The attempted operation cannot be ... to do it. Also I tried to reboot it, reset it but nothing is working and now it is not even in the running VMs list.
asked Feb 18, 2020 mphil 2.3k points
0 votes
1 answer 1.5K views
1.5K views
Problem : I am using windows 10. I also have Tensorflow on my box.It says "Hello Tensorflow!" to me. However it has all of below before it: 2019-12-05 18:16:01.500579: I T:\src\github\tensorflow\tensorflow\core\platform\ ... \numpy\\.libs\\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll' Consider using the--useroption or check the permissions. Any solution on this issue?
asked Dec 7, 2019 alecxe 7.5k points