this is my init routine


InitWinsock proc
local @stWsa:WSADATA
local @stSin:sockaddr_in

invoke WSAStartup,0002h,addr @stWsa
invoke socket,AF_INET,SOCK_STREAM,IPPROTO_TCP
mov hSocket,eax
invoke RtlZeroMemory,addr @stSin,sizeof @stSin
movzx eax,cfg.HTTPPort
invoke htons,eax
mov @stSin.sin_port,ax
mov @stSin.sin_family,AF_INET
mov @stSin.sin_addr,INADDR_ANY
invoke bind,hSocket,addr @stSin,sizeof @stSin
.if eax == SOCKET_ERROR
errclose "Error binding socket"
.else
invoke listen,hSocket,20
.endif
invoke CreateThread,0,0,addr ListenThread,0,0,0
invoke CloseHandle,eax

ret
InitWinsock endp


and this is listen thread:



ListenThread proc
LOCAL SockAddr:sockaddr_in
.while (1)
invoke accept,hSocket,addr SockAddr,sizeof SockAddr
debug
.if (eax == INVALID_SOCKET)
.break
.endif
invoke CreateThread, 0, 0, HTTPThread, eax, 0, 0
invoke CloseHandle,eax
.endw
ret
ListenThread endp


The problem is accept never blocked. Help me! Why!
Posted on 2003-09-29 09:14:28 by optimus
RTFM

Win32API.hlp for accept
This function extracts the first connection on the queue of pending connections on s, creates a new socket with the same properties as s and returns a handle to the new socket. If no pending connections are present on the queue, and the socket is not marked as nonblocking, accept blocks the caller until a connection is present. If the socket is marked nonblocking and no pending connections are present on the queue, accept returns an error as described following. The accepted socket may not be used to accept more connections. The original socket remains open.
Posted on 2003-09-30 00:09:26 by eet_1024