WSAGetLastError returns WSAENOTSOCK - Cause?

WSAGetLastError returns WSAENOTSOCK - Cause?

Content Index :

WSAGetLastError returns WSAENOTSOCK - Cause?
Tag : cpp , By : Patastroph
Date : November 27 2020, 01:01 AM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Win32 ::shutdown() returns -1, but WSAGetLastError() returns 0?

Tag : winapi , By : kakashi_
Date : March 29 2020, 07:55 AM
wish help you to fix your issue The answer ended up being that nearly any system calls can clear Win32's "LastError()" errors... In my case, throwing an exception meant formatting and logging a message, which caused the error to be clear... And even though I was calling WSAGetLastError() immediately in my catch(...) it was already too late...

WSAGetLastError() returns 122

Tag : cpp , By : Chandra P Singh
Date : March 29 2020, 07:55 AM
will be helpful for those in need The problem is your implementation of operator const char*(). Once that function returns, your stringstream object is no longer valid because it is no longer in scope.

WSAGetLastError() returns 64?

Tag : development , By : ap.
Date : March 29 2020, 07:55 AM
around this issue Socket error codes start at 10000. 64 is not a documented socket error code that WSAGetLastError() can return. However, Windows error code 64 is ERROR_NETNAME_DELETED ("The specified network name is no longer available.").

Why do I get the WSAENOTSOCK error in this code?

Tag : cpp , By : Mostapen
Date : March 29 2020, 07:55 AM
this will help You are initializing the Socket member to the wrong value in the Winsock constructor - NULL instead of INVALID_SOCKET. They are not the same value.
You are calling WSAAsyncSelect() regardless of whether socket() succeeds or fails. You are displaying error messages if things fail, but you are not stopping your code when they do fail. You need to clean up your error handling.
class Winsock

    void Initialize(HWND);

    void ReceiveMsg();

    SOCKET m_Socket;

    : m_Socket(INVALID_SOCKET)

void Winsock::Initialize(HWND hwnd)
    SendMessage(hwnd, LOG_ADD, 0, (LPARAM)L"Initializing winsock... ");

    WSADATA wsaDat = {0};
    if (WSAStartup(MAKEWORD(2,2), &wsaDat) != 0)
        SendMessage(hwnd, LOG_ADD, 0, (LPARAM)L"Winsock initialization failed");

    SendMessage(hwnd, LOG_ADD, 0, (LPARAM)L"Done!\nCreating a socket... ");

    m_Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (m_Socket == INVALID_SOCKET)
        SendMessage(hwnd, LOG_ADD, 0, (LPARAM)L"Socket Creation failed");

    SendMessage(hwnd, LOG_ADD, 0, (LPARAM)L"Done!\nRequesting Windows message-based notification of network events... ");

    if (WSAAsyncSelect(m_Socket, hwnd, WM_SOCKET, FD_CLOSE|FD_READ) != 0)
        SendMessage(hwnd, LOG_ADD, 0, (LPARAM)L"WSAAsyncSelect failed");

    /* More code */
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
        Game game;

void Game::CreateResources(HINSTANCE hInst)
    m_hWnd = CreateWindowClass(hInst);
    pMessageLog = CreateMessageLog();
    pD2DResources = CreateD2DResources(m_hWnd);
    pWinsock = CreateWinsock();

ConnectEx returns false and WSAGetLastError returns 0

Tag : development , By : francisco santos
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Missed some context in the problem description. The socket was bound to an I/O completion port. The function call failed but result of ConnectEx was received through GetQueuedCompletionStatus in a worker thread.
EDIT: I should have called WSAGetLastError() instead.
Related Posts Related QUESTIONS :
  • Why same char is not equal
  • Why does using a range for loop gives different output than using a regular for loop in this scenario?
  • Binary tree coding problems with c++?
  • How to safely change the type of a pointer
  • Can I get a pointer to a pointer pointing to nullptr, is it valid
  • Most elegant way to split a C++ TypeList
  • How to access element of JSON using Qt
  • find the inorder traversal of the tree and print them all by negating every alternate number
  • How to compile a static library with Codelite 11.0.0?
  • Could this publish / check-for-update class for a single writer + reader use memory_order_relaxed or acquire/release for
  • Passing a function identifier as an rvalue reference and applying std::move() to it
  • The conditional operator is not allowing the program to terminate
  • Define a c++ string as "\"
  • memcpy on __declspec naked returns unexpected bytes
  • What is the proper way to link enums with CMake?
  • is it safe to use the same mutex with lock_gard and without it in other parts of code
  • How to decode MAP Invoke messages using asn1c generated code
  • How do you write multiple lines in a .txt with recursion?
  • Member function with strange type causing callback function mismatch
  • Visual Studio optimisations break SDL graphical output
  • How to use less memory in Sieve_of_Eratosthenes
  • Covariance in Callback Parameters C++
  • switch may fall through (no it may not)
  • Compilation fails calling Cocoa function from C++
  • How to handle classes with differently named member functions in algorithms?
  • Convert QString to QJsonArray
  • Data exchange finished in CPropertyPage::OnOK?
  • Template member specialization in template class
  • Is it not possible to assign a struct to an index of a vector?
  • Why is empty unordered_map.find not returning end()?
  • Template argument deduction for inheriting specializations
  • dlopen undefined reference
  • Member function of class with template arguments and default arguments outside class
  • Is it possible to implement a non-owning "slightly smart" pointer on top of standard weak pointers?
  • how to configure the AcquireCredentialsHandleA correctly
  • Using private versions of global extern variables with OpenMP
  • Eigen Block wrong amount of columns and rows
  • Memory alignment rules in inheritance
  • Is nullptr falsy?
  • tm_wday returns a large integer outside 0-6 range
  • Scope a using declaration, inside a header
  • How to specify constructor's template arguments inside a new expression?
  • Sort an array via x86 Assembly (embedded in C++)?? Possible?
  • How to Replace only Part of the Variable using #define
  • How do you compare the performace of valarrays vs built-in arrays?
  • Is it normal for C++ static initialization to appear twice in the same backtrace?
  • c++ generate a good random seed for psudo random number generators
  • Why isn't my operator overloading working properly?
  • Getting meaningful error messages from fstream's in C++
  • C++: Converting Julian dates to Gregorian
  • Could someone explain this interesting behaviour with Sleep(1)?
  • Is it possible to roll a significantly faster version of modf
  • Updating pointer using signals and slots
  • How are classes more secure than structures?
  • finding "distance" between two pixel's colors
  • C++ Greatest Number Verification
  • Why does my token return NULL and how can I fix it?(c++)
  • C++ enforce conditions on inherited classes
  • what happened if an exception is not captured?
  • Redundant naming in C/C++ typedefs/structs
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com