Merci Orax d'avoir rectifié (IP du serveur à utiliser

)
Je viens de tester ce code entre 2 ordinateurs et ça marche
Pour le serveur
Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("SERVEUR", 240, 140, 192, 124)
Global $Input1 = GUICtrlCreateLabel("", 24, 8, 185, 25)
Global $Input2 = GUICtrlCreateInput("", 22, 42, 185, 25)
Global $Button1 = GUICtrlCreateButton("Envoi", 80, 88, 65, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
TCPStartup() ; Start the TCP service.
OnAutoItExitRegister("OnAutoItExit")
;$ip = TCPNameToIP("servehttp.hopto.org")
Local $IPAddress = @IPAddress1;"127.0.0.1" ; This IP Address only works for testing on your own computer.
Local $port = 80 ; Port used for the connection.
$listener = TCPListen($IPAddress,$port,10) ; création du socket d'écoute
If $listener = -1 Then ; si il y a une erreur, on l'affiche et on ferme service TCP et programme
MsgBox(16,"Erreur","Erreur lors de la création du socket d'écoute : n°" & @error)
TCPCloseSocket($listener)
TCPShutdown()
EndIf
Do ; Wait for someone to connect (Unlimited).
; Accept incomming connexions if present (Socket to close when finished; one socket per client).
$iSocket = TCPAccept($listener)
; If an error occurred display the error code and return False.
If @error Then
$iError = @error
MsgBox(0, "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError)
Exit
EndIf
Until $iSocket <> -1 ;if different from -1 a client is connected.
TCPCloseSocket($listener)
$temp = TCPRecv($iSocket,9999)
If $temp <> "Art14poM" Then
Exit
Else
TCPSend($iSocket,"44oilZAe")
EndIf
AdlibRegister("_TCP_Server",250)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
TCPShutdown()
Exit
Case $Button1
$envoi = GUICtrlRead($Input2)
TCPSend($iSocket,$envoi)
If @error Then ToolTip("erreur " & @error,100,100)
EndSwitch
WEnd
Func _TCP_Server()
ToolTip($iSocket,100,100)
$temp = TCPRecv($iSocket,9999) ; on attend la réception de données
If $temp = "FERMER" Then Exit
If $temp <> "" Then
GUICtrlSetData($Input1,$temp)
EndIf
EndFunc ;==>_TCPSend_Server
Func OnAutoItExit()
TCPShutdown() ; Close the TCP service.
EndFunc ;==>OnAutoItExit
Pour le client
Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("CLIENT", 240, 140, 600, 124)
Global $Input1 = GUICtrlCreateLabel("", 24, 8, 185, 25)
Global $Input2 = GUICtrlCreateInput("", 22, 42, 185, 25)
Global $Button1 = GUICtrlCreateButton("Envoi", 80, 88, 65, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
TCPStartup() ; le programme utilise désormais le protocole TCP/IP
;$ip = TCPNameToIP("servehttp.hopto.org")
Local $IPAddress = "192.168.1.10" ;"127.0.0.1" ; This IP Address only works for testing on your own computer.
Local $port = 80
$socket = TCPConnect($IPAddress,$port)
;$socket = TCPConnect($ip,$port) ; on tente une connexion à l'IP xxx.xxx.x.xxx
If $socket = -1 Or $socket = 0 Then ; si on ne peut pas se connecter
MsgBox(16,"", "Impossible de se connecter au serveur!")
TCPShutdown() ; le programme n'utilise plus le protocole TCP/IP
Exit ; on quitte le programme
EndIf
OnAutoItExitRegister("OnAutoItExit")
TCPSend($socket,"Art14poM")
Sleep(500)
$recoie = TCPRecv($socket,9999)
If $recoie <> "44oilZAe" Then
TCPSend($socket,"FERMER")
Sleep(500)
Exit
EndIf
AdlibRegister("TCP_client",250)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
TCPShutdown()
Exit
Case $Button1
$envoi = GUICtrlRead($Input2)
TCPSend($socket,$envoi)
EndSwitch
WEnd
Func TCP_client()
$recoie = TCPRecv($socket,9999)
If $recoie <> "" Then
GUICtrlSetData($Input1,$recoie)
EndIf
EndFunc
Func OnAutoItExit()
TCPShutdown() ; Close the TCP service.
EndFunc ;==>OnAutoItExit
Il faudra modifier l'IP 192.168.1.10
Vous pouvez communiquer avec ce système (envoie et réception)
Il faut lancer le serveur en premier
Et je précise que le code n'est pas de moi (matwachich ?)