Full code:

include '%include%\win32ax.inc'


strError db "Error", 0h

; Socket data
sock dd ?
wsadata WSADATA

HostName db "LocalHost", 0
Port dd 60

call connectToServer
invoke ExitProcess, 0

proc connectToServer

invoke WSAStartup, 101h, wsadata
cmp eax, 0
jne @@error

invoke socket, AF_INET, SOCK_STREAM, 0
cmp eax, 0 ; if eax != 0 -> INVALID_SOCKET
je @@error

mov [sock], eax

mov [sin.sin_family], AF_INET
invoke htons, Port
mov [sin.sin_port], ax

invoke gethostbyname, HostName
cmp eax, 0
je @@error
mov eax, [eax+12] ; this is from Iczelion winsock tutorial
mov eax, [eax]
mov eax, [eax]
mov [sin.sin_addr], eax

; here i've got error:
;0x2736 = "An operation was attempted on something that is not a socket."
invoke connect, sock, sin, sizeof.SOCKADDR_IN
cmp eax, -1 ; non blocking mode will always return SOCKET_ERROR = -1
je @@error

jmp @@exit
invoke WSAGetLastError ; How convert error number to string?
invoke MessageBox, NULL, strError, strError, MB_OK

invoke WSACleanup

.end start

The problem is that it can't connect to server (from PSDK, see attached file)
I am newbie so is there any guru who can help me a bit?
Posted on 2003-05-23 09:19:02 by maksa
I don't have enough time to have a detailed look on your source right now, but I've posted my working Winsock example in other thread, maybe it will help you?
Posted on 2003-05-23 12:17:25 by Tomasz Grysztar
Correct me if I'm wrong, but doesn't fasm require for memory access?
invoke connect, [sock], sin, sizeof.SOCKADDR_IN

instead of:
invoke connect, sock, sin, sizeof.SOCKADDR_IN

That would explain it, your version would pass the address of the socket instead of the socket itself.

Posted on 2003-05-23 12:26:35 by Thomas
Thanks Privalov!
Thanks Thomas!
I'll try it.
Posted on 2003-05-26 00:20:17 by maksa