Merci

Code : Tout sélectionner
Procedure FTP_Connect(Port.l)
Thread.l = OpenNetworkConnection(FTP\Url,Port)
If Thread
FTP\ConnectionID = Thread
Else
FTP\ConnectionID = -1
EndIf
EndProcedure
Code : Tout sélectionner
Procedure OpenNetworkConnectionEx(ServerName$, Port.l, TimeOut.l)
!Conn equ Esp+12
!Wsa equ Esp+28
!Tout equ Esp+428
!Wait equ Esp+436
!Sock equ Esp+444
WsaData.WSADATA
Connection.SOCKADDR_IN
TimeOuts.TIMEVAL
WaitSock.ULARGE_INTEGER
Sock.l
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
!if ~ defined _gethostbyname@4 | defined @f
!extrn _gethostbyname@4
!@@:
!end if
;
!if ~ defined _WSAStartup@8 | defined @f
!extrn _WSAStartup@8
!@@:
!end if
;
!if ~ defined _socket@12 | defined @f
!extrn _socket@12
!@@:
!end if
;
!if ~ defined _htons@4 | defined @f
!extrn _htons@4
!@@:
!end if
;
!if ~ defined _ioctlsocket@12 | defined @f
!extrn _ioctlsocket@12
!@@:
!end if
;
!if ~ defined _connect@12 | defined @f
!extrn _connect@12
!@@:
!end if
;
!if ~ defined _select@20 | defined @f
!extrn _select@20
!@@:
!end if
;
!if ~ defined _closesocket@4 | defined @f
!extrn _closesocket@4
!@@:
!end if
;
!if ~ defined _WSACleanup@0 | defined @f
!extrn _WSACleanup@0
!@@:
!end if
;;;;;;;;;;;;;;;;;;
!MOV Eax, [Esp]
!OR Eax, Eax
!JZ @f
!PUSH Eax
!CALL _gethostbyname@4
!OR Eax, Eax
!JZ @f
!MOVSX Ebx, word [Eax+8]
!CMP Ebx, 2
!JNE @f
!MOV Ecx, [Eax+12]
!MOV Ecx, [Ecx]
!MOV Ecx, [Ecx]
!MOV [Conn+4], Ecx
!LEA Eax, [Wsa]
!PUSH Eax
!PUSH $0002
!CALL _WSAStartup@8
!OR Eax, Eax
!JNZ @f
!CMP byte [Wsa], 2
!JL @f
!PUSH 6
!PUSH 1
!PUSH 2
!CALL _socket@12
!CMP Eax, -1
!JE @f
!MOV [Sock], Eax
!MOV word [Conn], 2
!PUSH dword [Esp+4]
!CALL _htons@4
!MOV word [Conn+2], ax
!MOV Eax, dword [Esp+8]
!MOV dword [Tout], Eax
!MOV dword [Wait], 1
!MOV Eax, dword [Sock]
!MOV dword [Wait+4], Eax
!LEA Eax, [Wait]
!PUSH Eax
!PUSH -2147195266
!PUSH dword [Sock+8]
!CALL _ioctlsocket@12
!PUSH dword 16
!LEA Eax, [Conn+4]
!PUSH Eax
!PUSH dword [Sock+8]
!CALL _connect@12
!LEA Eax, [Tout]
!PUSH Eax
!PUSH 0
!LEA Eax, [Wait+8]
!PUSH Eax
!PUSH 0
!PUSH 0
!CALL _select@20
!CMP Eax, 0
!JNA @f
!LEA Eax, [Tout+4]
!PUSH Eax
!PUSH -2147195266
!PUSH dword [Sock+8]
!CALL _ioctlsocket@12
!CALL _WSACleanup@0
!MOV Eax, [Sock]
ProcedureReturn
!@@:
!CMP dword [Sock], -1
!JNE @f
!PUSH dword [Sock]
!CALL _closesocket@4
!@@:
!CMP byte [Wsa], 0
!JE @f
!CALL _WSACleanup@0
!@@:
;;;;;;;;;;;;;
!Restore Conn
!Restore Wsa
!Restore Tout
!Restore Wait
!Restore Sock
EndProcedure
InitNetwork()
Host$ = "www.purearea.net"
ServerID = OpenNetworkConnectionEx(Host$, 80, 1)
If ServerID = 0
MessageRequester("", "Timeout")
Else
If SendNetworkString(ServerID, "GET / HTTP/1.1" + #CRLF$ + "Host: " + Host$ + #CRLF$ + #CRLF$)
Response$ = Space($FFF)
ResponseLen = Len(Response$)
Repeat
inLen = ReceiveNetworkData(ServerID, @Response$ + Pos, ResponseLen - pos)
Pos + inLen
Until inLen = 0 Or Pos = ResponseLen
MessageRequester("", Response$)
EndIf
CloseNetworkConnection(ServerID)
EndIf