I looked throw the board but couldn't find help, here is the stuation:

InitServer proc uses ebx


mov [hSocket], INVALID_SOCKET
invoke socket, AF_INET, SOCK_STREAM, IPPROTO_TCP
mov ecx, offset CreateSockError
mov herror,ecx
cmp eax, INVALID_SOCKET
je _error1
mov [hSocket], eax

invoke SetServerSockAddr
invoke bind, [hSocket], addr sockAddr, sizeof sockAddr
test eax, eax
mov ecx, offset g_errBind
mov herror,ecx
jnz _error2

invoke listen, [hSocket], 1
mov ecx, offset g_errListen
mov herror,ecx
jnz _error2
mov [clientSockSize], sizeof clientSockAddr

Cloop: ;<< my application Freezes
; when I come to this loop
mov [hClientSocket], INVALID_SOCKET
invoke accept, [hSocket], addr clientSockAddr, addr clientSockSize
cmp eax, INVALID_SOCKET
je Cloop
mov [hClientSocket], eax
mov ecx, offset g_msgDone
mov herror,ecx
mov eax, 0
ret

_error1:
mov eax,1 ;return 1 on error
ret

_error2:
mov eax, [hSocket]
cmp eax, INVALID_SOCKET
jne _error1
invoke closesocket, eax
jmp _error1

InitServer endp



How do I check for incoming connections and at the same time have the attantion of my application.

Peace
Posted on 2004-01-11 17:40:09 by mistronr1
OK I found a solution

I moved the connect part into a proc, and I call it in a new thred.

have a nice day
peace
Posted on 2004-01-11 23:02:42 by mistronr1
Actually, you might want to consider a whole nother approach. Instead of just looping on accept, create an event, and use wsawaitformultipleevents ... or use async sockets, and then give it your hwnd. In that case, you don't loop on accept, but wait for the event to be triggered, or an incoming message. Saves a HEAP. Look thru Icz tuts.

Fake
Posted on 2004-01-13 02:23:52 by Fake51
www.madwizard.org , 'nuff said.
Posted on 2004-01-13 08:47:10 by f0dder
Hi

F00der : I learnd everything I know about socket Programming from Thomas, but still the tutorial is not complet yet. I am waiting for the non-blocking part.

Fake51 : Thanks a lot, I found information about wsawaitformultipleevents at the MSDN, I will try it out. My application works fine as it is, but I still want to do it the right way.

Peace
Posted on 2004-01-13 19:02:36 by mistronr1