.586P
.MODEL FLAT, STDCALL
include \masm32\include\wsock32.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\wsock32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
CrearConexion proto
EnviarMensage proto
Error proto
.DATA
wsa WSADATA <> ; <--- ERROR Linea 30
sin SOCKADDR_IN <> ; <--- ERROR Linea 31
ip dq 0100007Fh
port dd 9a02h
buffsend db "#### barata", 0
cap db "Error", 0
txt db "Error no enviado", 0
cap2 db "Adios", 0
txt2 db "A funcado bien xDDD", 0
.DATA?
sock dd ?
.CONST
protocolo dd 06h; IPPROTO_TCP
familia dd 02h ; AF_INET
stream dd 01h ; SOCK_STREAM
sizesin dd 10h ; sizeof sockaddr_in
make dd 101h ; MAKEWORD(1,1)
wm_sock dd 464h; WM_SOCKET = WM_USER+100
f_connect dd 10h ; FD_CONNECT
f_read dd 01h ; FD_READ
f_close dd 20h ; FD_CLOSE
f_all dd 31h ; Suma de los 3
.CODE
Inicio:
xor eax, eax
call CrearConexion
push 00h
push offset cap
push offset txt
push 00h
call MessageBoxA
push sock
call closesocket
call WSACleanup
push 00h
call ExitProcess
end Inicio
CrearConexion proto
push offset wsa
push offset make
call WSAStartup
push offset protocolo
push offset stream
push offset familia
call socket
mov sock, eax
push offset f_all
push offset wm_sock
push 00h
push sock
call WSAAsyncSelect
mov sin.sin_family, offset familia
mov sin.sin_port, offset puerto
mov sin.sin_addr, offset ip
push offset sizesin
push offset sin
push offset sock
call connect
je EnviarMensage
jnz Error
ret; w0w
CrearConexion endp
EnviarMensage proto
push 00h
push 15
push offset sendbuff
push offset sock
call send
ret
EnviarMensage endp
Error proto
push 00h
push offset cap
push offset txt
push 00h
call MessageBoxA
push 00h
call ExitProcess
leave
ret; w0w
Error endp