hi @all, i have some trouble whit WSAEvents.
I searched and found many threads about the events (thx to savage for some code)
but it doesnt works correctly:

invoke WSAEventSelect, hServerSock,hEventObject,FD_ACCEPT+FD_READ+FD_CLOSE+FD_WRITE
invoke WSAWaitForMultipleEvents, 1, addr hEventObject, FALSE, INFINITE, FALSE
then:
invoke WSAEnumNetworkEvents, hServerSock, hEventObject, addr wsaRemoteEvents
and i test for events:
test wsaRemoteEvents.lNetworkEvents, FD_READ
but i got only the FD_ACCES event (8), nothing more!
in my debugger i see the first loop (WSAWaitForMultipleEvents)
then i connect whith a browser or telnet or another programm (headreq from thomas)
and get my FD_ACCES event (i accept)... then i got a zero event:
i see that "wsaRemoteEvents.lNetworkEvents" is zero... but WHAT is zero for a FD_xxx? After this "zero event" there is nothing, when i close my connecting program (telnet, headreq) i got a "zero event" too.
I tried to find it out about 2 days... its possible that i misunderstood something, but my "reading english" is not as bad as my "writing english" ;)
some code:




invoke WSACreateEvent
.if eax==0
invoke MessageBox,0,addr msg_event_error,addr msg_Error,MB_ICONERROR
jmp ENDE
.endif
mov hEventObject,eax


.data
hClientSock dd 0
testdata db "HTTP/1.0 200 OK",CR,LF,"Content-Lenght: 5",CR,LF,"Content-Type: text/plain",CR,LF,"Connection: close",CR,LF,CR,LF,"Hall?",0

.code

invoke WSAEventSelect, hServerSock, hEventObject,FD_ACCEPT+FD_READ+FD_CLOSE+FD_WRITE
@waitfornextevent:
invoke WSAWaitForMultipleEvents, 1, addr hEventObject, FALSE, INFINITE, FALSE
invoke WSAEnumNetworkEvents, hServerSock, hEventObject, addr wsaRemoteEvents

test wsaRemoteEvents.lNetworkEvents, FD_READ
jz @f
invoke MessageBox,0,0,0,MB_ICONASTERISK
invoke recv,hClientSock,addr msg_buffer,255,0
@@:
test wsaRemoteEvents.lNetworkEvents, FD_ACCEPT
jz @f
invoke MessageBox,0,0,0,MB_OK
invoke accept,hServerSock,0,0
mov hClientSock,eax

@@:
test wsaRemoteEvents.lNetworkEvents, FD_CLOSE
jz @f
invoke closesocket,hClientSock
@@:
test wsaRemoteEvents.lNetworkEvents, FD_WRITE

jz @f
invoke MessageBox,0,0,0,MB_ICONEXCLAMATION
invoke send,hClientSock,addr testdata,sizeof testdata,0
@@:

jmp @waitfornextevent



PS:it should be a small HTTP-server...



EDIT: 25.10.03 18:11:
I 'm good... i'm the best ... :rolleyes: i waste about 2-3 days to find the error... read
about 20 times msdn and thomas' winsocktut... and looked and rewrite about 100 times my code... but i dont see the logical error: first acept a conection and then

invoke WSAWaitForMultipleEvents, 1, addr hEventObject, FALSE, INFINITE, FALSE
invoke WSAEnumNetworkEvents, hClientSock, hEventObject, addr wsaRemoteEvents
listen to the CLIENT Sock for Messages...
:stupid:
Posted on 2003-10-25 05:28:21 by CDW
I took zero to mean that no events occurred within the timeout period, and just jump back to wait some more... also note that with the WSAWaitForMultipleEvents that you QUITE OFTEN get just that - multiple events !! Check for things like FD_READ+FD_CLOSE and not just the obvious :)
Posted on 2003-10-28 22:55:25 by Homer
my problem was that i looked for serversocketevents.

Check for things like FD_READ+FD_CLOSE and not just the obvious

i think i can do it whit 'test'
FD_READ equ 001h
FD_CLOSE equ 020h
so if you have a FD_READ+FD_CLOSE = 21h=0010 0001
i test for FD_READ only:
test eax,1 (1=>2^0=> so i test for bit 0)
first bit is set
i test for FD_CLOSE:
test eax,20h (20h=>32d=>2^5=> so i test if bit 5 is set ...
(you should not use "cmp" ;) )
but thx, i think i should check for FD_READ before i test for FD_CLOSE :D
Posted on 2003-10-29 06:45:05 by CDW