Hello everyone!
I've been working on a small project recently,which aimed to work under Windows.The whole idea is to make a programme that alert you when there's a new email in your mail box.
This would be a really easy task if i colud write it as a console app,but i can't...
I want the programme to work as a hidden process so i have to use Windows app.

So the problem is how to handle sockets in windows GUI.I.ve tried:

...

if(SOCKET_ERROR==WSAAsyncSelect(sock,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_WRITE)){
MessageBox(hwnd,"WSAAsyncSelect!","error",MB_OK);
closesocket(sock);
WSACleanup();
return TRUE;
}

...

case WM_SOCKET_NOTIFY:
Event=WSAGETSELECTEVENT(lParam);
Error=WSAGETSELECTERROR(lParam);

switch(Event){
case FD_CONNECT:
if(Error){
MessageBox(hwnd,"connect!","error",MB_OK);
return TRUE;
}
return 0;
case FD_READ:
Log("recv...");
recv(sock,buff,sizeof(buff)/sizeof(buff[0]),0);
Log(buff);
rmsg++;
return 0;
case FD_WRITE:
Log("send...");
send(sock,DoWyslania[smsg],20,0);
Log(DoWyslania[smsg]);
smsg++;

return 0;
case FD_CLOSE:
Log("!@#@!...");
PostQuitMessage(0);
return 0;
}
return 0;


case WM_DESTROY:
Log("===========end===============");
KillTimer(hwnd,ID_TIMER);
PostQuitMessage(0);
WSACleanup();
fclose(log);
return 0;
but it doesn't work properly...it send data when i want to receive it and stops after receiving one message.
i want to :
-connect to a server
-receive it's prompt
-send "USER xxx"
-recv prompt
-send "Pass xxx"
-recv prompt
-send "STAT"
-recv info about mailbox

how to do it?