;sock0b.asm
;12AGO2007
.586p
.model flat,stdcall
locals
jumps
include c:\tasm\include\windows.inc
include c:\tasm\include\wsocks.inc
;include c:\tasm\include\win32api.inc
extrn MessageBoxA:proc
extrn ExitProcess:proc
;extrn WSAStartup:proc
;extrn WSACleanup:proc
;extrn socket:proc
;extrn closesocket:proc
;extrn connect:proc
;extrn htons:proc
;extrn inet_addr:proc
.data
titulo db "Titulo",0
texto db "Texto",0
wsadstruct WSADATA <>
sock dd 0
saistruct SOCKADDR <>
ipaddress db "127.0.0.1",0
port dd 80
.code
main:
push offset wsadstruct
push 2h
call WSAStartup
cmp eax,NULL
jnz exitprog
push NULL
push SOCK_STREAM
push AF_INET
call socket
cmp eax,SOCKET_ERR
jz wscleanup
mov sock,eax
mov saistruct.sin_family,AF_INET
push port
call htons
mov saistruct.sin_port,ax
push offset ipaddress
call inet_addr
mov saistruct.sin_addr,eax
push 16
push offset saistruct
push [sock]
call connect
cmp eax,SOCKET_ERR
je closesock
push 0
push offset titulo
push offset texto
push 0
call MessageBoxA
closesock:
push [sock]
call closesocket
wscleanup:
call WSACleanup
exitprog:
push 0
call ExitProcess
end main
;EOS