Code : Tout sélectionner
;les includes etc
;déclaration des vars
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Serveur", 724, 532, 353, 284)
GUISetIcon("E:\Projet ISN\Scripts\Serveur partie\console-icone-6104.ico", -1)
GUISetFont(12, 400, 0, "Century Gothic")
Global $Input1 = GUICtrlCreateInput("", 128, 480, 457, 29)
Global $Button1 = GUICtrlCreateButton("EXECUTER", 592, 480, 99, 33)
Global $List1 = GUICtrlCreateList("", 128, 64, 561, 397 ,BitOR($GUI_SS_DEFAULT_LIST,$WS_HSCROLL))
GUICtrlSetFont(-1, 14, 800, 0, "Century Gothic")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
Global $Button2 = GUICtrlCreateButton("Aide", 40, 248, 51, 49)
Global $Label1 = GUICtrlCreateLabel("Console du serveur", 128, 32, 151, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
TCPStartup()
$listener = TCPListen($IPAddress,$port,$maxSockets)
GUICtrlSetData($List1,"[SERVEUR "&@HOUR&":"&@MIN&":"&@SEC&"] Tentative de création de socket en "&$port&"...") ;1er cas de figure
If $listener = -1 Then
GUICtrlSetData($List1,@CRLF&"[SERVEUR "&@HOUR&":"&@MIN&":"&@SEC&"] Erreur lors de la création du socket d'écoute : n°" & @error);2eme cas de figure
MsgBox(16,"Erreur","Erreur lors de la création du socket d'écoute : n°" & @error)
TCPCloseSocket($listener)
TCPShutdown()
Else
GUICtrlSetData($List1,"[SERVEUR "&@HOUR&":"&@MIN&":"&@SEC&"] Connection étalie avec succés!");2eme cas de figure
EndIf
While 1
If GUIGetMsg()=$Button1 Then
If GUICtrlRead($Input1)<>"" Then
GUICtrlSetData($List1,'De "'&@IPAddress1&'", '&@HOUR&':'&@MIN&':'&@SEC&' >> '&GUICtrlRead($Input1))
Switch GUICtrlRead($Input1)
Case "Exit"
For $i=5 to 0 Step -1
GUICtrlSetData($List1,GUICtrlRead($List1)&@CRLF&'[SERVEUR "&@HOUR&":"&@MIN&":"&@SEC&"] Le serveur se fermera dans '&$i&' secondes...') ;n eme cas de figure
Sleep(1000)
Next
_Exit()
EndSwitch
EndIf
EndIf
;reste du prog
WEnd