Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3950806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:39:19+00:00 2026-05-20T01:39:19+00:00

can any one point out the reason why u cant send and receive on

  • 0

can any one point out the reason why u cant send and receive on a socket at the same time ?

to my understanding there are 2 streams one to push and one to pull

if you attempt to send/receive simultaneously you will get wasealready error

what is the reason that the socket throws wasealready error (10035)
does it have any thing to do with the ack window the receiving side sends back ?
as if to keep the line open for the window ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:39:19+00:00Added an answer on May 20, 2026 at 1:39 am

    First, I think you’re confused with your error codes. Here’s a few codes that might be relevant:

    • WSAEALREADY (10037) – You attempt to issue a request that’s already in progress. Eg, trying to connect() with a socket that’s already in the middle of connecting.
    • WSAEINPROGRESS (10036) – You attempt to issue more than one blocking operation at once, even across multiple threads.
    • WSAEWOULDBLOCK (10035) – You attempt to make a call that would have blocked (eg, recv when there’s no data available) when the socket is in non-blocking mode.

    The main factor preventing you from doing two blocking operations at once is the WSAEINPROGRESS error – a limitation in the Winsock 1.1 API only allows you to do one blocking operation at once. You can get around this by using non-blocking overlapped calls and the Winsock 2.0 API to simulate blocking calls. For example:

    SOCKET sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
    WSAEVENT hEvent = WSACreateEvent();
    WSAEventSelect(sock, hEvent, FD_CONNECT); // register for connect notification
    long iMode=1;
    ioctlsocket(sock,FIONBIO,&iMode); // set non-blocking mode
    
    WSAConnect(sock, address, sizeof(address), NULL, NULL, NULL, NULL);
    WSAWaitForMultipleEvents(1, &events, FALSE, INFINITE, FALSE);
    
    WSANETWORKEVENTS connect_result;
    WSAEnumNetworkEvents(sock, hEvent, &connect_result);
    if (connect_result.iErrorCode[FD_CONNECT] != 0) {
      // connect failed, do something about it
    }
    WSACloseEvent(hEvent);
    
    iMode = 0;
    ioctlsocket(sock,FIONBIO,&iMode); // clear non-blocking mode; it won't play well with overlapped IO below
    
    // Start an overlapped send
    char *my_data = "Hello, world!";
    WSAOVERLAPPED send_overlapped;
    WSABUF send_buf;
    send_buf.len = strlen(my_data);
    send_buf.buf = my_data;
    send_overlapped.hEvent = WSACreateEvent();
    DWORD bytesSent;
    WSASend(sock, &send_buf, 1, &bytesSent, 0, &send_overlapped, NULL);
    if (WSAGetLastError() != WSA_IO_PENDING) {
        // something went wrong, handle the error...
    }
    
    
    // Start an overlapped receive
    char rdata[256];
    WSAOVERLAPPED recv_overlapped;
    WSABUF recv_buf;
    recv_buf.len = sizeof(rdata);
    recv_buf.buf = rdata;
    recv_overlapped.hEvent = WSACreateEvent();
    DWORD bytesRecvd;
    WSARecv(sock, &recv_buf, 1, &bytesRecvd, NULL, &recv_overlapped, NULL);
    if (WSAGetLastError() != WSA_IO_PENDING) {
        // something went wrong, handle the error...
    }
    
    // Now wait for both to finish
    WSAEVENT events[2];
    events[0] = recv_buf.hEvent;
    events[1] = send_buf.hEvent;
    WSAWaitForMultipleEvents(2, events, TRUE, INFINITE, TRUE);
    

    This approach is a bit more complex, but very flexible – once you fire off an overlapped I/O job, the very same thread can go on to do other work (as long as you keep the buffers and what not allocated!). The one thing to watch out for is that if you do this on your GUI thread, you’ll need to change the message loop – in order for overlapped events to complete, the thread that issued them needs to perform an alertable wait using eg MsgWaitForMultipleEvents. In the above example I’m using WSAWaitForMultipleEvents to perform this alertable wait. Also, the thread that issues an overlapped I/O request must not terminate until the request completes.

    For more general information on overlapped I/O, see this MSDN page: http://msdn.microsoft.com/en-us/library/ms686358(v=vs.85).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to try out SICP with Python. Can any one point to materials
Can anyone please point out what im doing wrong with this Stored Procedure please.
Can anyone point me out, how can I parse/evaluate HQL and get map where
Is there any other reason for implementing an hash code function for my types
Can anyone point me to a good resource (or throw me a clue) to
Can anyone point me in the right direction on this. From reading the FAQs
Can anyone point me to a good introduction to coding against the paypal API?
Can anyone point me to a tutorial on the best way to open a
Can anyone point to libraries that can be used for Printing from Compact .Net
Can anyone point me to a library for 2D game physics, etc for programming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.