I think I am doing this correctly? basically I am trying to send the word hello to a remote server, when I try this, the connection is established, but the information is not sent. (I am aware I am not closing the socket with the code I have written). I just don't understand why it isn't sending the data?



WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==IDM_CONNECT
invoke ConnectServer, hWnd
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp

ConnectServer proc hWnd


invoke WSAStartup, 101h, addr wsadata
.if eax!=NULL
invoke MessageBox, NULL, ADDR Error, ADDR Error, MB_OK
mov wsockerror, 0001h
ret
.else
invoke socket, AF_INET, SOCK_STREAM, 0
.if eax!=INVALID_SOCKET
mov sock, eax
.else
invoke MessageBox, NULL, ADDR Error, ADDR Error, MB_OK
mov wsockerror, 0001h
ret
.ENDIF
.ENDIF

mov sin.sin_family, AF_INET
invoke htons, Port
mov sin.sin_port, ax
invoke inet_addr, addr IPAddress
mov sin.sin_addr, eax
invoke connect, sock, addr sin, sizeof sin
.IF eax==INVALID_SOCKET
.IF eax !=WSAEWOULDBLOCK
invoke MessageBox, NULL, ADDR Error, ADDR Error, MB_OK
mov wsockerror, 0001h
.ENDIF
.ENDIF
invoke send, sock, datasent, 7, 0
ret
ConnectServer endp


Thanks
Cheeseball
Posted on 2002-02-17 01:16:34 by Cheeseball
invoke send, sock, datasent, 7, 0


If datasent is a buffer then you should specify it's offset otherwise it must be a dword pointing to the data buffer
Posted on 2002-02-17 01:34:49 by Quantum
does the server you are trying to connect to require authentication?

you might want to try to establish the string length using either the masm32 StrLen function or the windows api function lstrlen.


invoke StrLen,addr datasent
invoke send, sock, addr datasent, eax, 0


quantums explanation though probably solved your problem.
Posted on 2002-02-17 10:50:38 by smurf
That did solve the problem, I think I am going to run into other problems, (not the strlen one). But I guess I shall find that out when I get there...:)

Thanks for the help, I might be posting more "Stupid" mistakes later.........
Cheeseball
Posted on 2002-02-17 13:22:42 by Cheeseball