B  onjour à tous
 onjour à tous 
je souhaiterais  créer une petite applications client serveur qui permette  d'envoyer des messages vers un serveur 
de les afficher ligne par ligne...
exemple : toto commande une pizza puis titi commande une tarte flambée etc ....
Je suis donc parti d'un exemple de code basé sur la fonction TCP_Connect
l'exemple ci dessous  correspond à ce que je souhaiterais faire  à un détail prêt
Dans le code suivant je ne peux envoyer qu'un seul message.... 
est il possible de laisser la connexion au serveur ouverte  et d'envoyer des messages un derrière l'autre
et que l'on voit les messages se suivre ?
Le fait d'utiliser un socket ferme il systématiquement la liaison avec le serveur et dans ce cas faudrait il écrire l'information
dans un fichier  et afficher le contenu du dit fichier ?
En vous remerciant pour vos éclaircissement et conseils 
 
 
Jean-Marc
 
► Afficher le texte
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
    TCPStartup() ; Start the TCP service.
    Local $sIPAddress = "127.0.0.1" ; 
    Local $iPort = 65432 ; 
    #Region GUI
    Local $sTitle = "TCP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)
    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)
    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "TCP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyTCP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "TCP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyTCP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch
        Sleep(10)
    WEnd
    #EndRegion GUI
EndFunc   ;==>Example
Func MyTCP_Client($sIPAddress, $iPort)
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf
       ;TCPSend($iSocket, @crlf & "Un plat du jour pour Monsieur XXX "&@hour&@MIN&@CRLF)
       ;TCPSend($iSocket, "Un dessert pour  Monsieur XXX"& @hour&":"&@MIN &@CRLF)
       ;TCPSend($iSocket, "Un Coca pour  Monsieur XXX"& @hour&":"&@MIN & @CRLF)
       TCPSend($iSocket, "Un plat du jour pour Monsieur YYY"&@hour&":"&@MIN&  @CRLF)
            If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf
     ;TCPCloseSocket($iSocket)
EndFunc   ;    
Func MyTCP_Server($sIPAddress, $iPort)
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError)
        Return False
    EndIf
    Local $iSocket = 0
    Do 
        $iSocket = TCPAccept($iListenSocket)
            If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Return False
    Until $iSocket <> -1 ;
    ; Close the Listening socket to allow afterward binds.        ;TCPCloseSocket($iListenSocket)
    ; Assign a Local variable the data received.
    Local $sReceived = TCPRecv($iSocket, 2048) ;   
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)
    ; Close the socket.
   ; TCPCloseSocket($iSocket)
EndFunc   ;
;Func OnAutoItExit()
;    TCPShutdown() ; Close the TCP service.
;EndFunc   ;==>OnAutoItExit