http://msdn.microsoft.com/en-us/library/windows/desktop/ms737526(v=vs.85).aspx
Siguiendo con el estudio de WINSOCK estoy algo confundido con respecto a la API accept, ya que si pongo los parámetros:
Citar
_Out_ struct sockaddr *addr,
_Inout_ int *addrlen
_Inout_ int *addrlen
LÍNEA 55: invoke accept,sock,addr acpt,sizeof acpt
Este me arroja un error:
Código
TITLE cliente .386 option casemap:none .model flat,stdcall include c:\masm32\include\windows.inc include c:\masm32\include\user32.inc include c:\masm32\include\kernel32.inc include c:\masm32\include\ws2_32.inc includelib c:\masm32\lib\user32.lib includelib c:\masm32\lib\kernel32.lib includelib c:\masm32\lib\ws2_32.lib .const .data wsadata WSADATA <> sin sockaddr_in <> acpt sockaddr <> errort byte "Error Server",0 ; temp error1 byte "Error WSAStartup",0 ; temp error2 byte "Error socket",0 ; temp error3 byte "Error listen",0 ; temp error4 byte "Error bind",0 ; temp look byte "Conexión recibida",0 ; temp Port equ 61116 .data? sock SOCKET ? .code main PROC invoke WSAStartup,101h,addr wsadata .if eax!=NULL invoke MessageBox,NULL,addr error1,addr errort,MB_ICONERROR + MB_OK ; temp .else invoke socket,AF_INET,SOCK_STREAM,0 .if eax!=INVALID_SOCKET mov sock,eax mov sin.sin_family,AF_INET mov sin.sin_addr,INADDR_ANY invoke htons,Port mov sin.sin_port,ax invoke bind,sock,addr sin,sizeof sin .if eax!=SOCKET_ERROR invoke listen,sock,15 .if eax!=SOCKET_ERROR .while(TRUE) invoke accept,sock,addr acpt,sizeof acpt .if eax!=SOCKET_ERROR invoke MessageBox,NULL,addr look,addr errort,MB_ICONERROR + MB_OK ; temp .else invoke WSAGetLastError .endif .endw .else invoke MessageBox,NULL,addr error3,addr errort,MB_ICONERROR + MB_OK ; temp .endif .else invoke MessageBox,NULL,addr error4,addr errort,MB_ICONERROR + MB_OK ; temp .endif .else invoke MessageBox,NULL,addr error2,addr errort,MB_ICONERROR + MB_OK ; temp .endif .endif invoke ExitProcess,0 main ENDP END main
¿Cómo soluciono esto?
¿Para que sirve exactamente estos parámetros?
Gracias y saludos.
EDIT: El error generado al llamar accept es el siguiente:
271E (WSAEFAULT) An invalid argument was supplied to the Windows Sockets API.