Дописал (как мне казалось) программку http загрузки страницы из интернет при помощи сокета в неблокирующем режиме. Код не работает, не идет никак прием в recv, возвращается только WSAEWOULDBLOCK. Программка от этого тупо подвисает в бесконечном цикле. Поправьте меня, пожалуйста! Код (Text): .386 .model flat, stdcall option casemap :none include windows.inc include kernel32.inc include wsock32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib wsock32.lib includelib masm32.lib includelib debug.lib .data szHostname db "www.ya.ru",0 http_request db "GET / HTTP/1.1",13,10,\ "Host: www.ya.ru",13,10,\ "User-Agent: socket-c",13,10,13,10,0 .code socket_c proc LOCAL wsa:WSADATA LOCAL ip:DWORD LOCAL sock:DWORD LOCAL sadr:sockaddr_in LOCAL argp:DWORD LOCAL buff_sml:DWORD LOCAL buff_big:DWORD LOCAL buff_lmt:DWORD LOCAL buff_cnt:DWORD LOCAL recv_cnt:DWORD invoke WSAStartup,202h,addr wsa test eax,eax jnz exitproc invoke gethostbyname,addr szHostname test eax,eax jz cleanup assume eax:ptr hostent mov eax,[eax].h_list mov eax,dword ptr [eax] mov eax,dword ptr [eax] mov ip,eax invoke socket,AF_INET,SOCK_STREAM,0 test eax,SOCKET_ERROR jz cleanup mov sock,eax mov sadr.sin_family,AF_INET invoke htons,80 mov sadr.sin_port,ax mov eax,ip mov sadr.sin_addr,eax invoke RtlZeroMemory,addr sadr.sin_zero,8 invoke connect,sock,addr sadr,sizeof sadr test eax,eax jnz cleansock invoke send,sock,addr http_request,sizeof http_request,0 test eax,SOCKET_ERROR jz cleansock mov argp,1 invoke ioctlsocket,sock,FIONBIO,addr argp test eax,eax jnz cleansock invoke VirtualAlloc,0,4*1024,MEM_RESERVE,PAGE_READWRITE mov buff_sml,eax invoke VirtualAlloc,buff_sml,4*1024,MEM_COMMIT,PAGE_READWRITE invoke VirtualAlloc,0,1*1024*1024,MEM_RESERVE,PAGE_READWRITE mov buff_big,eax mov buff_lmt,4*1024 invoke VirtualAlloc,buff_big,buff_lmt,MEM_COMMIT,PAGE_READWRITE mov buff_cnt,0 .repeat invoke recv,sock,buff_sml,4*1024,0 mov recv_cnt,eax invoke WSAGetLastError .if recv_cnt!=0 && eax!=WSAEWOULDBLOCK add buff_cnt,eax mov eax,buff_lmt .while eax<buff_cnt add buff_lmt,4*1024 invoke VirtualAlloc,buff_big,buff_lmt,MEM_COMMIT,PAGE_READWRITE mov eax,buff_lmt .endw mov eax,buff_big add eax,buff_cnt sub eax,recv_cnt invoke RtlMoveMemory,eax,buff_sml,recv_cnt .endif mov eax,recv_cnt .until eax==0 PrintString buff_big invoke VirtualFree,buff_sml,0,MEM_RELEASE invoke VirtualFree,buff_big,0,MEM_RELEASE cleansock: invoke closesocket,sock cleanup: invoke WSACleanup exitproc: ret socket_c endp start: invoke socket_c invoke ExitProcess,0 end start