The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: LechooY on October 12, 2006, 04:49:44 PM

Title: Windows socket (WSAAsyncSelect) need help...
Post by: LechooY on October 12, 2006, 04:49:44 PM
Hello for All :)

I create my program in masm32 and I have litte problem by windows socket


Create socket:

   push FD_CONNECT + FD_CLOSE + FD_READ
   push WM_GG_SOCKET
   push hWnd
   push MySocket
   call WSAAsyncSelect

When I send file (Bufffer, wathever) of size >10 KB in loop (I send by 2000 bytes) then all work pefect...  :dance:

   push 0
   push eax ;2000
   push offset Buffer
   push MySocket
   call send   

instead when send fille more than 10 KB (50 KB) then I get error WSAEWOULDBLOCK (10035) :( and data is lost

My question is how I can eliminate that???

PS. Sorry for my bed english :(
Title: Re: Windows socket (WSAAsyncSelect) need help...
Post by: Tedd on October 12, 2006, 05:04:53 PM
You don't need to do anything.
When using WSAAsyncSelect you can treat WSAEWOULDBLOCK as a warning only, it doesn't mean the send has failed -- this is mentioned in the documentation :P
You can see this by testing that the data is still received by whomever you send it to :wink

IF this is using a STREAM_SOCKet only. For datagram sockets, you must send in small pieces - one at a time.
Title: Re: Windows socket (WSAAsyncSelect) need help...
Post by: LechooY on October 12, 2006, 05:12:37 PM
Yes I read this to

QuoteResource temporarily unavailable.
This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.

But its not work.. maybe I do some error maybe somebody have than same bug? Maybe a must use Blocking socket?
Title: Re: Windows socket (WSAAsyncSelect) need help...
Post by: James Ladd on October 12, 2006, 10:39:47 PM
The framework (WSA) is telling you that the operation would block.
In simple terms: This is because either the send needs to wait for space to be available in a send buffer, or because a read is
being done, but there is no data to read yet.

Since the example you mention has a "send" my question is , "what is at the other end receiving the data?"

If the other end isnt reading the data then there is going to be a block until it does.
Title: Re: Windows socket (WSAAsyncSelect) need help...
Post by: LechooY on October 13, 2006, 08:18:29 AM
I'm stupid idiot!  :dazzled:


I fund error. Thanks for help.
Title: Re: Windows socket (WSAAsyncSelect) need help...
Post by: James Ladd on October 13, 2006, 08:21:09 AM
What was the problem ?