Is there any solution for 10038 server error .i have done coding in c++;
the server runs fine 10 to 12 hours but sudenly it gives 10038 socket error
asked Oct 16, 2010 at 8:32
SunilRai86SunilRai86
9906 gold badges16 silver badges26 bronze badges
0
Without seeing your code: the symptom you describe sounds like you are leaking memory/resources, i.e. you are forgetting to free/delete objects you are allocating. It could also be a timing issue. I suggest you post your (cut-down) code.
10038 (WSAENOTSOCK): Socket operation on nonsocket. An operation
was attempted on something that is not
a socket. Either the socket handle
parameter did not reference a valid
socket, or for select, a member of an
fd_set was not valid.
answered Oct 16, 2010 at 8:34
Mitch WheatMitch Wheat
296k44 gold badges466 silver badges542 bronze badges
2
I bet you are accessing a socket that you already closed. This is a very common timing bug in WinSock programming — the good news (and bad news, because it’s hard to reproduce) is that you are not hitting it very often so it’s likely your code does not need much work to make it perfect. I think you should add thread-safe diagnostics that output a string including the socket value (an int
, basically) on every open and close, and from anywhere you see this 10038 or other unexpected errors.
If you can add those diagnostics and then set up a stress test that focuses on open and close areas in your program (you may need to strip down the code to a small subset for unit testing of the sockets handling, maybe doing this back-to-back on localhost, or to two LAN-connected machines) then it will likely manifest much more quickly than 10-12 hours and you may find and fix other timing windows along the way. The goal is to try to compress 10-12 hours of ‘normal’ socket activity into as small a space of time as possible, to really expose any hard-to-detect concurrency problems.
answered Oct 16, 2010 at 12:23
Steve TownsendSteve Townsend
53.5k9 gold badges91 silver badges140 bronze badges
There may be two reasons for this:
- Your socket descriptor in uninitialized (i.e. doesn’t reference a valid socket).
- You closed this socket (by a call to
closesocket
), and still try to use it.
Such an error is always a bug, it’s not related to the real network activity/state and etc. This is equivalent (in some sense) to either trying to use a resource/memory after you free it, or simply referencing an uninitialized pointer.
So that in order to solve the 10038 you must fix your code.
P.S. If you have a multi-threaded application — it’s likely that you close the socket in one thread, whereas the other thread still trying to use it.
Anyway, there’s a good practice to initialize socket descriptors to INVALID_SOCKET
at the beginning. Also set it to INVALID_SOCKET
immediately after you close it.
Then, before trying to use it you may check if the socket is valid. In such a way you may find the problematic scenario.
answered Oct 16, 2010 at 10:21
valdovaldo
12.7k2 gold badges37 silver badges68 bronze badges
Also look out for the fact that — at least in Windows — you will get 10038 if you try to send on a socket on one thread that was opened in a different thread.
answered Nov 9, 2017 at 18:17
Ted WTed W
2394 silver badges11 bronze badges
1
Is there any solution for 10038 server error .i have done coding in c++;
the server runs fine 10 to 12 hours but sudenly it gives 10038 socket error
asked Oct 16, 2010 at 8:32
SunilRai86SunilRai86
9906 gold badges16 silver badges26 bronze badges
0
Without seeing your code: the symptom you describe sounds like you are leaking memory/resources, i.e. you are forgetting to free/delete objects you are allocating. It could also be a timing issue. I suggest you post your (cut-down) code.
10038 (WSAENOTSOCK): Socket operation on nonsocket. An operation
was attempted on something that is not
a socket. Either the socket handle
parameter did not reference a valid
socket, or for select, a member of an
fd_set was not valid.
answered Oct 16, 2010 at 8:34
Mitch WheatMitch Wheat
296k44 gold badges466 silver badges542 bronze badges
2
I bet you are accessing a socket that you already closed. This is a very common timing bug in WinSock programming — the good news (and bad news, because it’s hard to reproduce) is that you are not hitting it very often so it’s likely your code does not need much work to make it perfect. I think you should add thread-safe diagnostics that output a string including the socket value (an int
, basically) on every open and close, and from anywhere you see this 10038 or other unexpected errors.
If you can add those diagnostics and then set up a stress test that focuses on open and close areas in your program (you may need to strip down the code to a small subset for unit testing of the sockets handling, maybe doing this back-to-back on localhost, or to two LAN-connected machines) then it will likely manifest much more quickly than 10-12 hours and you may find and fix other timing windows along the way. The goal is to try to compress 10-12 hours of ‘normal’ socket activity into as small a space of time as possible, to really expose any hard-to-detect concurrency problems.
answered Oct 16, 2010 at 12:23
Steve TownsendSteve Townsend
53.5k9 gold badges91 silver badges140 bronze badges
There may be two reasons for this:
- Your socket descriptor in uninitialized (i.e. doesn’t reference a valid socket).
- You closed this socket (by a call to
closesocket
), and still try to use it.
Such an error is always a bug, it’s not related to the real network activity/state and etc. This is equivalent (in some sense) to either trying to use a resource/memory after you free it, or simply referencing an uninitialized pointer.
So that in order to solve the 10038 you must fix your code.
P.S. If you have a multi-threaded application — it’s likely that you close the socket in one thread, whereas the other thread still trying to use it.
Anyway, there’s a good practice to initialize socket descriptors to INVALID_SOCKET
at the beginning. Also set it to INVALID_SOCKET
immediately after you close it.
Then, before trying to use it you may check if the socket is valid. In such a way you may find the problematic scenario.
answered Oct 16, 2010 at 10:21
valdovaldo
12.7k2 gold badges37 silver badges68 bronze badges
Also look out for the fact that — at least in Windows — you will get 10038 if you try to send on a socket on one thread that was opened in a different thread.
answered Nov 9, 2017 at 18:17
Ted WTed W
2394 silver badges11 bronze badges
1
Disabling your proxy server often fixes this issue
by Claire Moraa
Claire likes to think she’s got a knack for solving problems and improving the quality of life for those around her. Driven by the forces of rationality, curiosity,… read more
Updated on
- Winsock error 10038 occurs when you try to connect to a remote host and your computer fails to open a socket connection.
- Your firewall could be blocking such connections, so ensure you have allowed necessary exceptions before proceeding.
XINSTALL BY CLICKING THE DOWNLOAD FILE
Get rid of malfunctioning drivers on your PC
SPONSORED
Drivers can often become corrupt as they can interfere with malfunctioning system files, thus arriving to be installed but not running correctly. To keep your drivers running smoothly, your Windows OS must run even smoother. Get it in perfect shape by following the steps below:
- Download Fortect and install it on your PC.
- Start the tool’s scanning process to look for corrupt files that are the source of your problem
- Right-click on Start Repair so the tool can start the fixing algorithm
- Fortect has been downloaded by 0 readers this month, rated 4.4 on TrustPilot
Winsock error 10038 is a socket connection problem you may encounter when connecting to a remote server. Sockets are a way to send and receive data over a network. They can be used for many things, from sending emails to viewing web pages.
In this article, we’ll go over some of the most common causes and solutions for the socket connection error. We’ll also cover additional tips and tricks to help prevent this issue.
What is Winsock error 10038?
Winsock error 10038 is caused by problems with the Windows Sockets API, which is a part of the TCP/IP protocol suite. This is a set of communications protocols that send data between applications on a computer network.
If you are getting a socket connection error, it can be because of one of the following reasons.
- Firewall or antivirus is blocking the connection – The most common reason for this error is if one of your third-party firewall or antivirus products has been updated recently. When this happens, they sometimes reset TCP/IP settings to default.
- Wrong credentials – You might have entered the wrong password in the connection settings, especially if it is case-sensitive.
- Connection issues – Sometimes, the network you are using may be down or slow for other reasons.
- Incorrect or corrupt IP address – This can happen if you have recently changed your DNS settings or there is no connection between your local area network and the Internet.
- Proxy server – If you’re using a proxy server, your connection may be interrupted because it limits access to certain sites.
How do I fix a socket connection error?
Attempt the following basic workarounds before the advanced steps:
- Close all programs that you have running.
- Check your cables and plugs and ensure they are securely connected to both devices.
- Verify that you have entered the correct password when connecting.
- Perform a network speed test to rule out the possibility of a slow connection.
- Check if your firewall is enabled and allow an exception for the program you are trying to run.
- Ensure your antivirus software is up-to-date.
- Restart your router, modem, and PC again, if necessary.
1. Disable your antivirus temporarily
- Hit the Start menu icon, type Windows Security in the search bar, and click Open.
- Click on Firewall & network protection, then select Public network.
- Locate Microsoft Defender Firewall and toggle the off button.
2. Update your network drivers
- Hit the Windows key, type Device Manager in the search bar, and click Open.
- Navigate to Network adapters and click to expand. Right-click on the driver, then click Update driver from the drop-down.
- Select the Search automatically for drivers option and wait till the update finishes.
- Restart your PC and check if the error persists.
Another way to get things done faster and more accurately is to use a third-party driver updater utility. This is one sure way of ensuring you’re getting the correct drivers for your PC.
Even better, you don’t have to move a finger because Outbyte Driver Updater will automatically do the job for you. It will scan, detect, download, and install the driver from its wide database in a matter of seconds.
⇒ Get Outbyte Driver Updater
3. Disable Proxy
- Press the Windows key and select Settings.
- Click on Network & Internet on the left pane, then scroll down and click Proxy on the right pane.
- Select Edit next to Use a proxy server option in the Manual proxy setup section, toggle off Use a proxy server and click on Save.
- Restart your PC and see if the issue persists.
- Fix: No Internet in Windows 11 Safe Mode With Networking
- Fix: System has a Driver Locked to Manufacturer Specifications
- 4 Ways to Fix LiveKernelEvent 144 Error on Windows 11
- Fix: Secure Boot is Greyed Out on Windows 11
- Fix: Touchpad Clicks but Doesn’t Move on Windows 11
4. Reset TCP/IP
- Click on the Start Menu icon, type cmd in the search bar, and click Open.
- Type in the following commands and press Enter after each one:
netsh winsock reset catalog
netsh int ipv4 reset reset.log
netsh int ipv6 reset reset.log
- Now restart your PC and see if the error is still there.
Resetting TCP/IP removes your computer’s network settings and forces it to re-establish them from scratch. This includes everything from your IP address to your proxy settings.
It can resolve problems such as an unresponsive connection to the Internet or unexpected loss of connectivity.
In conclusion, if you are facing the problem of Winsock error 10038 and want to fix it, you only need to follow the steps we have listed above. Hopefully, one of the above methods will work for you.
Unfortunately, Winsock errors are common, so we try our best to come up with solutions for most of them. To that effect, we’d like to direct you to another wholesome article on the Winsock error 10051 and see our recommended fixes.
And with that, we sign out but keep it interactive in the comment section below with more tips and tricks.
Citrix Socket Error 10038
-
View Larger Image
Citrix Socket Error 10038
“Unable to connect to the server. Contact your system administrator with the following error: Socket operation on non-socket (Socket Error 10038)”
The dreaded message when using Citrix Receiver.
Happens with Citrix Receiver 4.11 and 4.12 – quickest solution is to remove the current version of Citrix Receiver and install Citrix Receiver 4.9 ( available here: https://www.citrix.com/downloads/citrix-receiver/legacy-receiver-for-windows/receiver-for-windows-49LTSR.html )
I’ve also uploaded a copy here: https://www.rgb.ie/citrix_receiver_v4.9.exe
More information
In March 2018, Microsoft announced a newly discovered vulnerability in the CredSSP protocol, which is used by Remote Desktop Connection to authenticate your password or smart card using Network Level Authentication (NLA). The flaw could allow someone to capture your credentials if he has access to the traffic between your client computer and the target. The above 10038 error occurs if one system is updated and the other system is not.
Best to patch those remote terminals! 🙂
About the Author: Media Team
All enquiries can be sent to pr@rgb.ie
Related Posts
-
Operation Triangulation – iOS devices targeted with previously unknown malware
Operation Triangulation – iOS devices targeted with previously unknown malware
-
Microsoft 365
Gallery
Microsoft 365
-
Managed IT Service Solutions
Gallery
Managed IT Service Solutions
-
Panasonic KX UT Series – Reboot on attended transfer with 3CX V18 in the cloud
Gallery
Panasonic KX UT Series – Reboot on attended transfer with 3CX V18 in the cloud
-
Hosted Phone Solutions, VoIP and Microsoft 365 Integration – UPGRADE TODAY!
Gallery
Hosted Phone Solutions, VoIP and Microsoft 365 Integration – UPGRADE TODAY!
3 Comments
-
ytdfghg
February 11, 2020 at 8:26 am — Replythank you its working
you save me -
Utkarsh Gupta
April 6, 2020 at 7:27 pm — ReplyHi,
Perfect solution to the problem. Resolved my critical issue.
-
Rakshith
April 8, 2020 at 9:33 am — ReplySame the socket error 10038 reflects .. please help me .. wat is the proceger I need to do .
Leave A Comment Cancel reply
Δ
Go to Top
Answer by Valeria Wiggins
Calculate the standard error of the difference between two independent proportions
,Asking for help, clarification, or responding to other answers.,
FizzBuzz, but with provided start and end of sequence, results stored in array, and a separate function to convert integers to strings
,
Jobs
Programming & related technical career opportunities
You are closing the clientsock after reading only part of the data.
clientsock.close()
Answer by Dayana McCoy
python socket programming [WinError 10038] An operation was attempted on something that is not a socket,I’m currently following a tutorial on python socket programming because I wanna learn how to make a small chat application with python.
https://www.youtube.com/watch?v=3QiPPX-KeSc,Looking back at his code and mine, I don’t see anything I’ve done wrong.
I’ve looked at other questions about this error on here, none of them answer what I’m currently having problems with.,
How can I check that a value exists in a dictionary or not in python
Though upon connecting to the server with my client, I get this error on the server:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:UsersuserAppDataLocalProgramsPythonPython39libthreading.py", line 954, in _bootstrap_inner
self.run()
File "C:UsersuserAppDataLocalProgramsPythonPython39libthreading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "c:UsersuserDesktopprogramingsocketserver.py", line 27, in handle_c
msg_l = conn.recv(header).decode(format)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
here is the code for my server:
import socket
import threading
print("nPlease input the IP address and port.nInput 0 if you want to resort to the default values")
server = input("IP: ")
port = int(input("Port: "))
if(server=="0"):
server=socket.gethostbyname(socket.gethostname())
if(port==0):
port=5050
header = 64
addr = (server, port)
format="utf-8"
disconnm = "!disconnect"
state = ["[starting]", "[connection]"]
sserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sserver.bind(addr)
def handle_c(conn, addr):
print(f"{state[1]} connection from {addr}")
connected = True
while connected:
msg_l = conn.recv(header).decode(format)
if msg_l:
msg_l = int(msg_l)
msg = conn.recv(msg_l).decode(format)
if msg == disconnm:
connected = False
print(f"[{addr}] {msg}")
conn.close()
def start():
print("{} server is starting..".format(state[0]))
sserver.listen()
print(f"{state[0]} server is listening for connections on {server}:{port}")
while True:
conn, addr = sserver.accept()
thread = threading.Thread(target=handle_c, args=(conn, addr))
thread.start()
print(f"{state[1]}, {threading.active_count() - 1}")
start()
client:
import socket
print("nPlease input the IP address and port of the server you want to connect to.")
server = input("IP: ")
port = int(input("Port: "))
addr = (server, port)
header = 64
format="utf-8"
disconnm = "!disconnect"
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(addr)
Answer by Santos Drake
sock = socket.socket()
sock.bind((address, port))
sock.listen(5)
client_sock, client_address = self.sock.accept()
while True:
data = client_socket.recv(1024)
msg = 'Server got: ' + data.decode()
client_socket.sendall(msg.encode())
client_socket.close()
sock = socket.socket()
sock.connect(server_address)
sock.sendall(request.encode())
data = sock.recv(1024)
while data:
print(data.decode())
data = sock.recv(1024)
sock.close()
Answer by Reed Benton
Note** this option does not delete the question immediately,Since others contribution also matters and security reasons.Your request will be Queued.We will review the question and remove.It may take some days.,If you add any files,it will delete all existing files related to this question-(questions only answer remains unchanged),is at the wrong level of indentation. Move it to the left by one step.,If you add any files,it will delete all existing files related to this answer-(only this answer)
I am working on this code
from socket import *
HOST = 'localhost'
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST, PORT)
serversock = socket(AF_INET, SOCK_STREAM)
serversock.bind(ADDR)
serversock.listen(2)
while 1:
print ("waiting on connection")
clientsock, addr = serversock.accept()
print ('connected from:', addr)
while 1:
data = clientsock.recv(1024).decode()
if not data: break
clientsock.send(data.encode())
clientsock.close()
serversock.close()
I get this error:
OSError: [WinError 10038] an operation was attempted on something that is not a socket
Answer by Blaze Weaver
关于python — OSError : [WinError 10038] An operation was attempted on something that is not a socket,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/27369137/
,… Note that on Windows, it only works for sockets; on other operating
systems, it also works for other file types …,
原文
标签
python
sockets
我在这里测试客户端方案
服务器和客户端使用相同的端口9009进行连接
以下代码以某种方式给我OSError,如标题所示:
import sys
import socket
import select
def chat_client():
if(len(sys.argv) < 3) :
print ('Usage : python chat_client.py hostname port')
sys.exit()
host = sys.argv[1]
port = int(sys.argv[2])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
# connect to remote host
try :
s.connect((host, port))
except :
print ('Unable to connect')
sys.exit()
print ('Connected to remote host. You can start sending messages')
sys.stdout.write('[Me] '); sys.stdout.flush()
while 1:
socket_list = [sys.stdin, s]
# Get the list sockets which are readable
ready_to_read,ready_to_write,in_error = select.select(socket_list,[],[])
# the timeout argument is omitted in above code,so chat_client blocks until a fd is ready
for sock in ready_to_read:
if sock == s:
# incoming message from remote server, s
data = sock.recv(4096) # sock.recv argument is buffsize, recommend 4096
if not data : # if not (data is not none), data is empty
print ('\nDisconnected from chat server')
sys.exit()
else : # data has something
#print data
sys.stdout.write(data) # write something to standard output buffer
sys.stdout.write('[Me] '); sys.stdout.flush() # write everything to terminal from buffer
else : # sock ! = s
# user entered a message
msg = sys.stdin.readline() # readline pick up everything from stdin
s.send(msg)
sys.stdout.write('[Me] '); sys.stdout.flush()
if __name__ == "__main__":
sys.exit(chat_client())
socket_list = [sys.stdin, s]
# Get the list sockets which are readable
ready_to_read,ready_to_write,in_error = select.select(socket_list,[],[])
Answer by Cal Townsend
I was reading up on Python Networking using sockets and found the code below at the end. I have the server file which works fine and starts the server on port 9009.,Also, reading on similar questions I have found out that
sys.stdin is not a socket so that could be why I’m
getting this error. Is there anything I can do to fix this?,Also, reading on similar questions I have found out that sys.stdin is not a socket so that could be why I’m getting this error. Is there anything I can do to fix this?,Note that in this example approach, when one began typing in a line, incoming messages will only be displayed after the input line is finished.
I was reading up on Python Networking using sockets and found the code below at the end. I have the server file which works fine and starts the server on port 9009.
# chat_client.py
import sys, socket, select
def chat_client():
if(len(sys.argv) < 3) :
print ('Usage : python chat_client.py hostname port')
sys.exit()
host = sys.argv[1]
port = int(sys.argv[2])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
# connect to remote host
try :
s.connect((host, port))
except :
print ('Unable to connect')
sys.exit()
print ('Connected to remote host. You can start sending messages')
sys.stdout.write('[Me] '); sys.stdout.flush()
while 1:
socket_list = [sys.stdin, s]
# Get the list sockets which are readable
read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
for sock in read_sockets:
if sock == s:
# incoming message from remote server, s
data = sock.recv(4096)
if not data :
print('\nDisconnected from chat server')
sys.exit()
else :
#print data
sys.stdout.write(data)
sys.stdout.write('[Me] '); sys.stdout.flush()
else :
# user entered a message
msg = sys.stdin.readline()
s.send(msg)
sys.stdout.write('[Me] '); sys.stdout.flush()
if __name__ == "__main__":
sys.exit(chat_client())
However, when I try the client part above, I get:
OSError: [WinError 10038] An operation was attempted on something that is not a socket
The lines where the errors are coming from are:
read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
and
sys.exit(chat_client())
Answer by Miles Carter
I created a server/client code to create a chat room using socket programming and multi-threading.I encountered an error that i dont seem to understand The server code is working, but i am facing issues with the client code and idk why it is saying its not a socket. i would appreciate any help on this., Save my name, email, and website in this browser for the next time I comment.
Client code
import socket
import select
import sys
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# if len(sys.argv) != 3:
# print ("missing arguments enter: <IP address> <port number>")
# exit()
IP_address="127.0.0.1"
Port = 12000
server.connect((IP_address, Port))
while True:
# create a list to maintain possible input streams
sockets_list = [sys.stdin, server]
""" Two possible inputs scenarios. Either the
user enters text to send to other clients, or the
server is sending a message to the client. """
""" select system call returns from sockets_list, the stream
that is reader for input. So for example, if the server sent a message, then the if condition will hold true below.
If the user wants to send a message, the else
condition will evaluate as true"""
print("wait on select call...")
read_sockets, write_sockets, error_sockets = select.select(sockets_list,[],[])
print("select call returned")
print("read_sockets: ", read_sockets)
#print("write_sockets: ", write_sockets)
#print("error_sockets: ", error_sockets)
for socks in read_sockets:
if socks == server:
message = socks.recv(4096)
if(len(message) != 0):
print(message)
# server sent empty message, print error and leave
else:
print("Server is down, join later once it is up!")
exit()
else:
message = sys.stdin.readline()
server.send(message)
sys.stdout.write("<You>")
sys.stdout.write(message)
sys.stdout.flush()
server.close()
output on client
Traceback (most recent call last):
File "C:/Users/a/Desktop/Network Programming 2/chat-client.py", line 23, in <module>
read_sockets, write_sockets, error_sockets = select.select(sockets_list,[],[])
OSError: [WinError 10038] An operation was attempted on something that is not a socket
wait on select call...