News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

window socket problem

Started by fushiyun, May 13, 2008, 06:42:35 AM

Previous topic - Next topic

fushiyun

i am programming socket program.
but i met a problem that i can't get the written pending queue size in socket.

for Unix/Linux, it can be obtained by using ioctlsocket function with FIONWRITE flag.
but in window platform, it don't has this falg.

it will return SOCKET_ERROR when the send function fail, meaning that it maybe be disconnected.
i must to maintain the sent data and don't lose.
so, can anyone tell me how to do it or give me some suggestions.
thank.

bozo

from http://msdn.microsoft.com/en-us/library/ms738573(VS.85).aspx

QuoteFIONREAD
Use to determine the amount of data pending in the network's input buffer that can be read from socket s. The argp parameter points to an unsigned long value in which ioctlsocket stores the result. FIONREAD returns the amount of data that can be read in a single call to the recv function, which may not be the same as the total amount of data queued on the socket. If s is message oriented (for example, type SOCK_DGRAM), FIONREAD still returns the amount of pending data in the network buffer, however, the amount that can actually be read in a single call to the recv function is limited to the data size written in the send or sendto function call.
[/i]

in assembly, the start function


; return zero for error, otherwise number of bytes pending

IsDataPending PROC USES ESI s:SOCKET
        LOCAL argp :DWORD
       
        lea esi,[argp]
        push esi
        push FIONREAD
        push dword ptr[s]
        call ioctlsocket
        inc eax
        jz socket_error
        lodsd
socket_error:
        ret
IsDataPending ENDP


this is not a function i'd use for tcp/ip programming, but just example of what you might want in asm..