Bind Error 10038
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have socket error 10038 Meta Discuss the workings and policies of this site About Us socket error codes linux Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with what is a socket error us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just socket error 10022 like you, helping each other. Join them; it only takes a minute: Sign up bind() fails with windows socket error 10038 up vote -1 down vote favorite I'm trying to write a simple program that will receive a string of max 20 characters and print that string to the screen. The code compiles, but I get
10038 Winsock
a bind() failed: 10038. After looking up the error number on msdn (socket operation on nonsocket), I changed some code from int sock; to SOCKET sock which shouldn't make a difference, but one never knows. Here's the code: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
Wsaenotsock 10038
company Business Learn more about hiring developers or posting ads with us Stack Overflow winsock error 10060 Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 winsock error 10038 fix million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up 10038 socket error up vote 3 down vote favorite 1 Is there any solution for 10038 server error .i http://stackoverflow.com/questions/2891865/bind-fails-with-windows-socket-error-10038 have done coding in c++; the server runs fine 10 to 12 hours but sudenly it gives 10038 socket error c++ visual-c++ sockets share|improve this question edited Oct 16 '10 at 9:00 asked Oct 16 '10 at 8:32 SunilRai86 34231025 add a comment| 3 Answers 3 active oldest votes up vote 6 down vote Without seeing your code: the symptom you describe sounds like you are leaking memory/resources, i.e. you are forgetting to http://stackoverflow.com/questions/3948164/10038-socket-error 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. share|improve this answer answered Oct 16 '10 at 8:34 Mitch Wheat 214k28345442 1 downvoters please leave a comment. –Mitch Wheat Jan 30 at 0:00 Can you explain the cryptic: "An operation was attempted on something that is not a socket" –Silvester Aug 11 at 8:53 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Subscribed! Success! Please click the link in the confirmation email to activate your subscription. up vote 6 down vote 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
Forum Visual C++ & C++ Programming Visual C++ Programming socket function returning = 10038 If this is your first http://forums.codeguru.com/showthread.php?510511-socket-function-returning-10038 visit, be sure to check out the FAQ by clicking the link http://forum.vingrad.ru/forum/topic-91040.html above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: socket function returning = 10038 Tweet socket error Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode March 27th, 2011,07:00 PM #1 Alphadan View Profile View Forum Posts Member Join Date Feb 2009 Posts 252 socket function returning = 10038 Code: bool CSocketComm::ConnectTo(LPCTSTR strDestination, LPCTSTR strServiceName, int nFamily, int nType){ // Socket is bind error 10038 already opened if ( IsOpen() ){ return false; } // Create a Socket that is bound to a specific service provide // nFamily: (AF_INET) // nType: (SOCK_STREAM, SOCK_DGRAM) WSASetLastError(0); SOCKET sock = socket(nFamily, nType, 0); if (INVALID_SOCKET != sock){ // Associate a local address with the socket SockAddrIn sockAddr; if (false == sockAddr.CreateFrom(NULL, TEXT("0"), nFamily)){ closesocket( sock ); return false; } if ( SOCKET_ERROR == bind(sock, sockAddr, sockAddr.Size() )){ closesocket( sock ); return false; } // Now get destination address & port sockAddr.CreateFrom( strDestination, strServiceName ); // try to connect - if fail, server not ready if (SOCKET_ERROR == connect( sock, sockAddr, sockAddr.Size())){ closesocket( sock ); return false; } // Success, now we may save this socket m_hComm = (HANDLE) sock; Inactive=false; //Allocacion para el IncBuffer IncBuffer.reserve(1024*512); //512 KB //Reseting Porcentaje=0; Total=0; Progreso=0; PckType=0; }else{ Fncs.Loguear("socket returned Invalid Handle",WSAGetLastError()); } //Fncs.Loguear("WSAErr",WSAGetLastError()); return (INVALID_SOCKET != sock); } why would the socket Function return INVALID_SOCKET and in the WSAGetLastError return 10038 Wich is: WSAENOTSOCK 10038 Socket operation on nonsocket. An operation was attempted on something that is not a
Выслать повторно письмо для активации Форум программистов Vingrad Новости · Фриланс · FAQ Правила · Помощь · Рейтинг · Избранное · Поиск · Участники Форум->Программирование->C++->C/C++: Сети (еще) Модераторы: feodorv Поиск: error 10038, в функции bind() Опции темы L0n3R4ng3r Дата 8.4.2006, 20:11 (ссылка) | (нет голосов) Загрузка ... Новичок Профиль Группа: Участник Сообщений: 12 Регистрация: 8.4.2006 Репутация: нет Всего: нет Вообщем обстоятельства и желания заставили меня учить работу с сокетами, почитав немого книжечку про создания сетевых приложения в Линуксе и порывшись в гугле и MSDN, я написал вот такое вот чудо:Код
/*---------------Simpletcpechoserver-----------------------*/
#include"stdafx.h"
#include"Winsock2.h"
#include"Windows.h"
#include"Winbase.h"
#include"stdio.h"
#include"WINSOCK.H"
#include"string.h"
#pragmacomment(lib,"ws2_32.lib")
intmain()
{
intsd;
intbindw;
sockaddr_inaddr_in;
sockaddrasd;
ZeroMemory(&asd,sizeof(asd));
charbuff[1024];
if(WSAStartup(0x202,(WSADATA*)&buff[0]))
{
printf("WSAStarterror%d\n",WSAGetLastError());
return-1;
}
if(sd=socket(AF_INET,SOCK_STREAM,0)>=0)
printf("%s\n","thesocketissuccessfullcreate");
else
{
printf("Errorbind%d\n",WSAGetLastError());
closesocket(sd);
WSACleanup();
return-1;
}
ZeroMemory(&addr_in,sizeof(addr_in));
addr_in.sin_family=AF_INET;
addr_in.sin_addr.S_un.S_addr=htons(INADDR_LOOPBACK);
addr_in.sin_port=htons(8025);//argv[2];
if(bindw=bind(sd