Jump to content

tcp connection problem


Recommended Posts

hi guy i try to understund  how  work a tcp protocol in autoit

i did  do this  script  for scan  a  port  ,in  another  pc  i start  a server   but  if i write  directli ip  , the script connected , if ip is in variable or in array dont  work , how  is possible???

the script client

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.14.2
    Author:         Faustf

    Script Function:  Grossiti Grab
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <array.au3>
#include <File.au3>
#include <GuiIPAddress.au3>
#include <GuiListView.au3>



;#include "spider-esprinet3.au3"

#NoTrayIcon

Opt("GuiOnEventMode", 1)
Opt("GUICloseOnESC", 0)
Opt("GUIResizeMode", 128)

;-----------------------   variables
Global $Checkbox35
Global $Checkbox1, $Checkbox2, $Checkbox3, $Checkbox4, $Checkbox5
Global $Checkbox6, $Checkbox7, $Checkbox8, $Checkbox9, $Checkbox10
Global $Checkbox11, $Checkbox12, $Checkbox13, $Checkbox14, $Checkbox15
Global $Checkbox16, $Checkbox17, $Checkbox18, $Checkbox19, $Checkbox20
Global $Checkbox21, $Checkbox23, $Checkbox24, $Checkbox25, $Checkbox26
Global $Checkbox22, $Checkbox27, $Checkbox28, $Checkbox29, $Checkbox30
Global $Checkbox31, $Checkbox32, $Checkbox33, $Checkbox34, $Checkbox35
Global $MenuItem2, $MenuItem4, $MenuItem5, $MenuItem3, $MenuItem1
Global $MenuItem6, $MenuItem7, $Input1, $Input2, $user, $pass
Global $flag1, $flag2, $flag3, $flag4, $flag5
Global $flag6, $flag7, $flag8, $flag9, $flag10
Global $flag11, $flag12, $flag13, $flag14, $flag15
Global $flag16, $flag17, $flag18, $flag19, $flag20
Global $flag21, $flag22, $flag23, $flag24, $flag25
Global $flag26, $flag27, $flag28, $flag29, $flag30
Global $flag31, $flag32, $flag33, $flag34, $flag35
Global $sFilePath = @ScriptDir & "\tmp_conf.txt"
Global $sFilePath_link = @ScriptDir & "\Temp_Espri\Gruppi_link_1.txt"
Global $sFilePath_categorie = @ScriptDir & "\Temp_Espri\Gruppi_1.txt"
Global $sFilePath_link2 = @ScriptDir & "\Temp_Espri\Gruppi_link_2.txt"
Global $sFilePath_categorie2 = @ScriptDir & "\Temp_Espri\Gruppi_2.txt"
Global $sFilePath_link3 = @ScriptDir & "\Temp_Espri\Gruppi_link_3.txt"
Global $sFilePath_categorie3 = @ScriptDir & "\Temp_Espri\Gruppi_3.txt"
Global $a = 1, $b = 35
Global $sFile = @ScriptDir & "\spider-esprinet3.exe", $iPID
Global $List1, $Checkbox36, $IPAddress1, $Button3, $Button4, $StatusBar1
Global $Button5, $Input3, $Input4, $Label3, $Label4, $IP_Adrss, $IP_Port = 3356
;------------------------------------

_GUI()



Func _GUI()

    $Form2 = GUICreate("GGrabber", 1197, 766, 374, 116)
    $MenuItem2 = GUICtrlCreateMenu("&File")
    $MenuItem6 = GUICtrlCreateMenuItem("Start", $MenuItem2)
    $MenuItem7 = GUICtrlCreateMenuItem("", $MenuItem2)
    $MenuItem8 = GUICtrlCreateMenuItem("Esci", $MenuItem2)
    $MenuItem1 = GUICtrlCreateMenu("&Aiuto")
    $MenuItem5 = GUICtrlCreateMenuItem("R.I.P", $MenuItem1)
    $MenuItem4 = GUICtrlCreateMenuItem("About", $MenuItem1)

    Local $StatusParts[4] = [250, 510, -1]
    $StatusBar1 = _GUICtrlStatusBar_Create($Form2)
    _GUICtrlStatusBar_SetParts($StatusBar1, $StatusParts)
    $Group1 = GUICtrlCreateGroup("", 0, 0, 1195, 726)
    $Group2 = GUICtrlCreateGroup("", 4, 531, 1187, 191)
    $Button2 = GUICtrlCreateButton("Start", 1130, 695, 51, 21)
    $Input2 = GUICtrlCreateInput("", 1060, 664, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
    $Input1 = GUICtrlCreateInput("", 1060, 639, 121, 21)
    $Label1 = GUICtrlCreateLabel("User:", 1025, 641, 29, 17)
    $Label2 = GUICtrlCreateLabel("Pass:", 1024, 667, 30, 17)
    $Button1 = GUICtrlCreateButton("", 1138, 543, 38, 37, BitOR($BS_NOTIFY, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\icon\Svengraph.ico", -1)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Pic1 = GUICtrlCreatePic(@ScriptDir & "\icon\tasti_espri.jpg", 48, 24, 236, 500)
    $Checkbox1 = GUICtrlCreateCheckbox("", 28, 47, 17, 17)
    $Pic2 = GUICtrlCreatePic(@ScriptDir & "\icon\tasti_espri2.jpg", 344, 24, 236, 500)
    $Pic3 = GUICtrlCreatePic(@ScriptDir & "\icon\tasti_espri3.jpg", 648, 16, 236, 460)
    $Pic4 = GUICtrlCreatePic(@ScriptDir & "\icon\tasti_espri4.jpg", 944, 22, 228, 454)
    $Checkbox2 = GUICtrlCreateCheckbox("", 324, 46, 17, 17)
    $Checkbox3 = GUICtrlCreateCheckbox("", 629, 45, 17, 17)
    $Checkbox4 = GUICtrlCreateCheckbox("", 925, 44, 17, 17)
    $Checkbox5 = GUICtrlCreateCheckbox("", 28, 104, 17, 17)
    $Checkbox6 = GUICtrlCreateCheckbox("", 324, 104, 17, 17)
    $Checkbox7 = GUICtrlCreateCheckbox("", 629, 105, 17, 17)
    $Checkbox8 = GUICtrlCreateCheckbox("", 925, 106, 17, 17)
    $Checkbox9 = GUICtrlCreateCheckbox("", 28, 163, 17, 17)
    $Checkbox10 = GUICtrlCreateCheckbox("", 324, 164, 17, 17)
    $Checkbox11 = GUICtrlCreateCheckbox("", 629, 162, 17, 17)
    $Checkbox12 = GUICtrlCreateCheckbox("", 925, 167, 17, 17)
    $Checkbox13 = GUICtrlCreateCheckbox("", 28, 214, 17, 17)
    $Checkbox14 = GUICtrlCreateCheckbox("", 324, 217, 17, 17)
    $Checkbox15 = GUICtrlCreateCheckbox("", 629, 217, 17, 17)
    $Checkbox16 = GUICtrlCreateCheckbox("", 925, 222, 17, 17)
    $Checkbox17 = GUICtrlCreateCheckbox("", 28, 269, 17, 17)
    $Checkbox18 = GUICtrlCreateCheckbox("", 324, 271, 17, 17)
    $Checkbox19 = GUICtrlCreateCheckbox("", 629, 269, 17, 17)
    $Checkbox20 = GUICtrlCreateCheckbox("", 925, 273, 17, 17)
    $Checkbox21 = GUICtrlCreateCheckbox("", 28, 330, 17, 17)
    $Checkbox22 = GUICtrlCreateCheckbox("", 324, 328, 17, 17)
    $Checkbox23 = GUICtrlCreateCheckbox("", 629, 329, 17, 17)
    $Checkbox24 = GUICtrlCreateCheckbox("", 925, 332, 17, 17)
    $Checkbox25 = GUICtrlCreateCheckbox("", 28, 385, 17, 17)
    $Checkbox26 = GUICtrlCreateCheckbox("", 324, 385, 17, 17)
    $Checkbox27 = GUICtrlCreateCheckbox("", 629, 383, 17, 17)
    $Checkbox28 = GUICtrlCreateCheckbox("", 925, 386, 17, 17)
    $Checkbox29 = GUICtrlCreateCheckbox("", 28, 440, 17, 17)
    $Checkbox30 = GUICtrlCreateCheckbox("", 324, 443, 17, 17)
    $Checkbox31 = GUICtrlCreateCheckbox("", 629, 433, 17, 17)
    $Checkbox32 = GUICtrlCreateCheckbox("", 925, 443, 17, 17)
    $Checkbox33 = GUICtrlCreateCheckbox("", 28, 497, 17, 17)
    $Checkbox34 = GUICtrlCreateCheckbox("", 324, 492, 17, 17)
    $Checkbox35 = GUICtrlCreateCheckbox("Seleziona Tutti", 629, 504, 97, 17)


    $List1 = GUICtrlCreateListView("Slave | Categorie Assegnate", 160, 543, 449, 175, $LVS_NOSCROLL)

    _GUICtrlListView_SetExtendedListViewStyle($List1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES)) ; questa stringa fa la griglia stile excel
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) ; cod. distr
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 345) ; descrizione
    GUICtrlSetState($List1, $GUI_DISABLE)

    $Checkbox36 = GUICtrlCreateCheckbox("Multi Scraper", 16, 552, 89, 17)
    $IP_Adrss = StringSplit(@IPAddress1, '.')

    $Label3 = GUICtrlCreateLabel($IP_Adrss[1] & '.' & $IP_Adrss[2] & '.' & $IP_Adrss[3], 16, 580, 52, 17)
    GUICtrlSetState($Label3, $GUI_DISABLE)
    $Label4 = GUICtrlCreateLabel($IP_Adrss[1] & '.' & $IP_Adrss[2] & '.' & $IP_Adrss[3], 16, 613, 51, 17)
    GUICtrlSetState($Label4, $GUI_DISABLE)
    $Input3 = GUICtrlCreateInput("001", 71, 578, 25, 21)
    GUICtrlSetState($Input3, $GUI_DISABLE)
    $Input4 = GUICtrlCreateInput("255", 71, 611, 25, 21)
    GUICtrlSetState($Input4, $GUI_DISABLE)
    $IPAddress1 = _GUICtrlIpAddress_Create($Form2, 13, 667, 130, 21)
    _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
    ControlDisable($IPAddress1, "", $IPAddress1)
    $Button5 = GUICtrlCreateButton("Add", 115, 694, 38, 21)
    GUICtrlSetState($Button5, $GUI_DISABLE)
    $Label5 = GUICtrlCreateLabel("IP Slave", 16, 650, 44, 14)

    $Button4 = GUICtrlCreateButton("Kill Process", 624, 552, 72, 21)
    GUICtrlSetState($Button4, $GUI_DISABLE)
    $Button3 = GUICtrlCreateButton("Scan", 116, 578, 38, 21)
    GUICtrlSetState($Button3, $GUI_DISABLE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)

    _imposta_configurazione()

    GUISetOnEvent($GUI_EVENT_CLOSE, "_close")
    GUICtrlSetOnEvent($Checkbox35, "_Tutti_select")
    GUICtrlSetOnEvent($Button1, "_sound")
    GUICtrlSetOnEvent($MenuItem5, "_morto_del_mese")
    GUICtrlSetOnEvent($MenuItem8, "_close")
    GUICtrlSetOnEvent($Button2, "_start")
    GUICtrlSetOnEvent($MenuItem6, "_start")
    GUICtrlSetOnEvent($Checkbox36, "_Scrap_Multi_ON")
    GUICtrlSetOnEvent($Button3, "_Scan_IP")


EndFunc   ;==>_GUI


Func _Scan_IP()
    Local $iSocket
    Local $IP_Start = GUICtrlRead($Input3)
    Local $IP_End = GUICtrlRead($Input4)
    Local $z = 0
    Local $Range = $IP_Adrss[1] & "." & $IP_Adrss[2] & "." & $IP_Adrss[3] & "."
    Local $Address[$IP_End]
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")



    For $i = $IP_Start To ($IP_End)


        $Address[$z] = $Range & $i

          $iSocket = TCPConnect( $Address[$z], $IP_Port)
        ;$iSocket = TCPConnect("192.168.1.106", 3356)
        Local $iError = 0

        ; If an error occurred display the error code and return False.
        If @error Then
            ; The server is probably offline/port is not opened on the server.
            ;$iError = @error
            ;MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
            ;Return False
        Else
            MsgBox(0, '', 'connessione avveuta')
        EndIf

        $z += 1
    Next
    _ArrayDisplay($Address)
    Local $aArrayUnique = _ArrayUnique($Address) ; Use default parameters to create a unique array.
    _ArrayDisplay($aArrayUnique, "$aArray Unique")
    ; Close the socket.
    TCPCloseSocket($iSocket)

    _Display()
EndFunc   ;==>_Scan_IP

Func _Display()
    ;GUICtrlSetData($Progress, ($Finished / 255) * 100)
    ;GUICtrlSetData($CurrentlyScanning, $CurrentIP)
    _GUICtrlStatusBar_SetText($StatusBar1, "Used IP Addresses: ", 0);& $CurrentIndex, 0)
    _GUICtrlStatusBar_SetText($StatusBar1, "Free IP Addresses: ", 1);& $FreeCount, 1)
EndFunc   ;==>_Display

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit




Func _Scrap_Multi_ON()

    Local $state_check36 = GUICtrlRead($Checkbox36)

    If $state_check36 = 1 Then ;  cioè è cliccato
        GUICtrlSetState($Label3, $GUI_ENABLE)
        GUICtrlSetState($Label4, $GUI_ENABLE)
        GUICtrlSetState($Input3, $GUI_ENABLE)
        GUICtrlSetState($Input4, $GUI_ENABLE)
        WinSetState($IPAddress1, "", @SW_ENABLE)
        GUICtrlSetState($Button5, $GUI_ENABLE)
        GUICtrlSetState($Button4, $GUI_ENABLE)
        GUICtrlSetState($List1, $GUI_ENABLE)
        GUICtrlSetState($Button3, $GUI_ENABLE)
    Else
        GUICtrlSetState($Label3, $GUI_DISABLE)
        GUICtrlSetState($Label4, $GUI_DISABLE)
        GUICtrlSetState($Input3, $GUI_DISABLE)
        GUICtrlSetState($Input4, $GUI_DISABLE)
        WinSetState($IPAddress1, "", @SW_DISABLE)
        GUICtrlSetState($Button5, $GUI_DISABLE)
        GUICtrlSetState($Button4, $GUI_DISABLE)
        GUICtrlSetState($List1, $GUI_DISABLE)
        GUICtrlSetState($Button3, $GUI_DISABLE)
    EndIf

EndFunc   ;==>_Scrap_Multi_ON





Func _start()

    _legge_ceckbox()

    _memoria_impostazioni()

    Local $iDelete = FileDelete($sFilePath_categorie)
    If $iDelete = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non cè il File di configurazione da cancellare")
        Return False
    EndIf

    Local $iDelete2 = FileDelete($sFilePath_link)
    If $iDelete2 = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non cè il File di configurazione da cancellare")
        Return False
    EndIf



    Local $iDelete_2 = FileDelete($sFilePath_categorie2)
    If $iDelete_2 = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non cè il File di configurazione da cancellare")
        Return False
    EndIf

    Local $iDelete_2_2 = FileDelete($sFilePath_link2)
    If $iDelete_2_2 = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non cè il File di configurazione da cancellare")
        Return False
    EndIf

    Local $iDelete_3 = FileDelete($sFilePath_categorie3)
    If $iDelete_3 = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non cè il File di configurazione da cancellare")
        Return False
    EndIf

    Local $iDelete_3_3 = FileDelete($sFilePath_link3)
    If $iDelete_3_3 = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non cè il File di configurazione da cancellare")
        Return False
    EndIf


    Local $hFileOpen_category = FileOpen($sFilePath_categorie, $FO_APPEND)
    If $hFileOpen_category = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Errore lettura categorie nomi")
        Return False
    EndIf

    Local $hFileOpen_link = FileOpen($sFilePath_link, $FO_APPEND)
    If $hFileOpen_link = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Errore lettura link categorie ")
        Return False
    EndIf



    ; Write data to the file using the handle returned by FileOpen.
    If $flag1 = 1 Then
        FileWrite($hFileOpen_category, 'AUDIO' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=9' & @CRLF)
    EndIf
    If $flag2 = 1 Then
        FileWrite($hFileOpen_category, 'BORSE / ZAINI / VALIGIE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=8' & @CRLF)
    EndIf
    If $flag3 = 1 Then
        FileWrite($hFileOpen_category, 'CARTA / CONSUMABILI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=62' & @CRLF)
    EndIf
    If $flag4 = 1 Then
        FileWrite($hFileOpen_category, 'CASA / TEMPO LIBERO' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=5' & @CRLF)
    EndIf
    If $flag5 = 1 Then
        FileWrite($hFileOpen_category, 'CAVETTERIA' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=16' & @CRLF)
    EndIf
    If $flag6 = 1 Then
        FileWrite($hFileOpen_category, 'CD / DVD / FLOPPY / NASTRI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=33' & @CRLF)
    EndIf
    If $flag7 = 1 Then
        FileWrite($hFileOpen_category, 'CLIMA' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=3' & @CRLF)
    EndIf
    If $flag8 = 1 Then
        FileWrite($hFileOpen_category, 'COMPONENTI PC' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=11' & @CRLF)
    EndIf
    If $flag9 = 1 Then
        FileWrite($hFileOpen_category, 'DISPOSITIVI DI ARCHIVIAZIONE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=13' & @CRLF)
    EndIf
    If $flag10 = 1 Then
        FileWrite($hFileOpen_category, 'ELETTRODOMESTICI GRANDI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=1' & @CRLF)
    EndIf
    If $flag11 = 1 Then
        FileWrite($hFileOpen_category, 'ELETTRODOMESTICI PICCOLI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=2' & @CRLF)
    EndIf
    If $flag12 = 1 Then
        FileWrite($hFileOpen_category, 'FOTOGRAFIA / VIDEO' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=17' & @CRLF)
    EndIf
    If $flag13 = 1 Then
        FileWrite($hFileOpen_category, 'GAMES' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=18' & @CRLF)
    EndIf
    If $flag14 = 1 Then
        FileWrite($hFileOpen_category, 'HOME VIDEO' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=52' & @CRLF)
    EndIf
    If $flag15 = 1 Then
        FileWrite($hFileOpen_category, 'MAT. ELETTRICO INDUSTRIALE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=74' & @CRLF)
    EndIf
    If $flag16 = 1 Then
        FileWrite($hFileOpen_category, 'MAT. ELETTRICO RESIDENZIALE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=76' & @CRLF)
    EndIf
    If $flag17 = 1 Then
        FileWrite($hFileOpen_category, 'MATERIALE ILLUMINAZIONE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=75' & @CRLF)
    EndIf
    If $flag18 = 1 Then
        FileWrite($hFileOpen_category, 'MONITOR' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=29' & @CRLF)
    EndIf
    If $flag19 = 1 Then
        FileWrite($hFileOpen_category, 'MULTIFUNZIONE / COPIATRICI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=38' & @CRLF)
    EndIf
    If $flag20 = 1 Then
        FileWrite($hFileOpen_category, 'NAVIGAZIONE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=72' & @CRLF)
    EndIf
    If $flag21 = 1 Then
        FileWrite($hFileOpen_category, 'NETWORKING/VOIP' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=20' & @CRLF)
    EndIf
    If $flag22 = 1 Then
        FileWrite($hFileOpen_category, 'NOTEBOOK / ULTRABOOK' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=32' & @CRLF)
    EndIf
    If $flag23 = 1 Then
        FileWrite($hFileOpen_category, 'PC / WORKSTATION' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=56' & @CRLF)
    EndIf
    If $flag24 = 1 Then
        FileWrite($hFileOpen_category, 'PERIFERICHE INPUT' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=46' & @CRLF)
    EndIf
    If $flag25 = 1 Then
        FileWrite($hFileOpen_category, 'PRODOTTI UFFICIO / CANCELLERIA' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=58' & @CRLF)
    EndIf
    If $flag26 = 1 Then
        FileWrite($hFileOpen_category, 'SCANNER / LETTORI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=40' & @CRLF)
    EndIf
    If $flag27 = 1 Then
        FileWrite($hFileOpen_category, 'SERVER / UPS' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=25' & @CRLF)
    EndIf
    If $flag28 = 1 Then
        FileWrite($hFileOpen_category, 'SOFTWARE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=61' & @CRLF)
    EndIf
    If $flag29 = 1 Then
        FileWrite($hFileOpen_category, 'STAMPANTI / PLOTTER' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=37' & @CRLF)
    EndIf
    If $flag30 = 1 Then
        FileWrite($hFileOpen_category, 'TABLET/E-BOOK/PDA' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=71' & @CRLF)
    EndIf
    If $flag31 = 1 Then
        FileWrite($hFileOpen_category, 'TELEFONIA' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=44' & @CRLF)
    EndIf
    If $flag32 = 1 Then
        FileWrite($hFileOpen_category, 'TELEVISORI' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=23' & @CRLF)
    EndIf
    If $flag33 = 1 Then
        FileWrite($hFileOpen_category, 'VIDEOCONFERENZA / SECURITY' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=47' & @CRLF)
    EndIf
    If $flag34 = 1 Then
        FileWrite($hFileOpen_category, 'VIDEOPROIEZIONE / LAVAGNE' & @CRLF)
        FileWrite($hFileOpen_link, 'http://www.esprinet.com/b2b/Ricerche/FantaRicerca/ElencoCategorie?filterid=60' & @CRLF)
    EndIf

    FileClose($hFileOpen_category)
    FileClose($hFileOpen_link)

    Local $iPID = ShellExecute($sFile)


EndFunc   ;==>_start



Func _imposta_configurazione()

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf
    Local $sFileRead[38]

    ; Read the contents of the file using the handle returned by FileOpen.
    Do
        $sFileRead[$a] = FileReadLine($hFileOpen, $a)
        $a += 1
    Until $a = 38

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    If $sFileRead[1] = 1 Then
        GUICtrlSetState($Checkbox1, $GUI_CHECKED)
    EndIf
    If $sFileRead[2] = 1 Then
        GUICtrlSetState($Checkbox2, $GUI_CHECKED)
    EndIf
    If $sFileRead[3] = 1 Then
        GUICtrlSetState($Checkbox3, $GUI_CHECKED)
    EndIf
    If $sFileRead[4] = 1 Then
        GUICtrlSetState($Checkbox4, $GUI_CHECKED)
    EndIf
    If $sFileRead[5] = 1 Then
        GUICtrlSetState($Checkbox5, $GUI_CHECKED)
    EndIf
    If $sFileRead[6] = 1 Then
        GUICtrlSetState($Checkbox6, $GUI_CHECKED)
    EndIf
    If $sFileRead[7] = 1 Then
        GUICtrlSetState($Checkbox7, $GUI_CHECKED)
    EndIf
    If $sFileRead[8] = 1 Then
        GUICtrlSetState($Checkbox8, $GUI_CHECKED)
    EndIf
    If $sFileRead[9] = 1 Then
        GUICtrlSetState($Checkbox9, $GUI_CHECKED)
    EndIf
    If $sFileRead[10] = 1 Then
        GUICtrlSetState($Checkbox10, $GUI_CHECKED)
    EndIf
    If $sFileRead[11] = 1 Then
        GUICtrlSetState($Checkbox11, $GUI_CHECKED)
    EndIf
    If $sFileRead[12] = 1 Then
        GUICtrlSetState($Checkbox12, $GUI_CHECKED)
    EndIf
    If $sFileRead[13] = 1 Then
        GUICtrlSetState($Checkbox13, $GUI_CHECKED)
    EndIf
    If $sFileRead[14] = 1 Then
        GUICtrlSetState($Checkbox14, $GUI_CHECKED)
    EndIf
    If $sFileRead[15] = 1 Then
        GUICtrlSetState($Checkbox15, $GUI_CHECKED)
    EndIf
    If $sFileRead[16] = 1 Then
        GUICtrlSetState($Checkbox16, $GUI_CHECKED)
    EndIf
    If $sFileRead[17] = 1 Then
        GUICtrlSetState($Checkbox17, $GUI_CHECKED)
    EndIf
    If $sFileRead[18] = 1 Then
        GUICtrlSetState($Checkbox18, $GUI_CHECKED)
    EndIf
    If $sFileRead[19] = 1 Then
        GUICtrlSetState($Checkbox19, $GUI_CHECKED)
    EndIf
    If $sFileRead[20] = 1 Then
        GUICtrlSetState($Checkbox20, $GUI_CHECKED)
    EndIf
    If $sFileRead[21] = 1 Then
        GUICtrlSetState($Checkbox21, $GUI_CHECKED)
    EndIf
    If $sFileRead[22] = 1 Then
        GUICtrlSetState($Checkbox23, $GUI_CHECKED)
    EndIf
    If $sFileRead[23] = 1 Then
        GUICtrlSetState($Checkbox24, $GUI_CHECKED)
    EndIf
    If $sFileRead[24] = 1 Then
        GUICtrlSetState($Checkbox25, $GUI_CHECKED)
    EndIf
    If $sFileRead[25] = 1 Then
        GUICtrlSetState($Checkbox26, $GUI_CHECKED)
    EndIf
    If $sFileRead[26] = 1 Then
        GUICtrlSetState($Checkbox22, $GUI_CHECKED)
    EndIf
    If $sFileRead[27] = 1 Then
        GUICtrlSetState($Checkbox27, $GUI_CHECKED)
    EndIf
    If $sFileRead[28] = 1 Then
        GUICtrlSetState($Checkbox28, $GUI_CHECKED)
    EndIf
    If $sFileRead[29] = 1 Then
        GUICtrlSetState($Checkbox29, $GUI_CHECKED)
    EndIf
    If $sFileRead[30] = 1 Then
        GUICtrlSetState($Checkbox30, $GUI_CHECKED)
    EndIf
    If $sFileRead[31] = 1 Then
        GUICtrlSetState($Checkbox31, $GUI_CHECKED)
    EndIf
    If $sFileRead[32] = 1 Then
        GUICtrlSetState($Checkbox32, $GUI_CHECKED)
    EndIf
    If $sFileRead[33] = 1 Then
        GUICtrlSetState($Checkbox33, $GUI_CHECKED)
    EndIf
    If $sFileRead[34] = 1 Then
        GUICtrlSetState($Checkbox34, $GUI_CHECKED)
    EndIf
    If $sFileRead[35] = 1 Then
        GUICtrlSetState($Checkbox35, $GUI_CHECKED)
    EndIf
    If $sFileRead[36] <> '' Then
        GUICtrlSetData($Input1, $sFileRead[36])
    EndIf
    If $sFileRead[37] <> '' Then
        GUICtrlSetData($Input2, $sFileRead[37])
    EndIf

EndFunc   ;==>_imposta_configurazione


Func _legge_ceckbox()

    $flag1 = GUICtrlRead($Checkbox1)
    $flag2 = GUICtrlRead($Checkbox2)
    $flag3 = GUICtrlRead($Checkbox3)
    $flag4 = GUICtrlRead($Checkbox4)
    $flag5 = GUICtrlRead($Checkbox5)
    $flag6 = GUICtrlRead($Checkbox6)
    $flag7 = GUICtrlRead($Checkbox7)
    $flag8 = GUICtrlRead($Checkbox8)
    $flag9 = GUICtrlRead($Checkbox9)
    $flag10 = GUICtrlRead($Checkbox10)
    $flag11 = GUICtrlRead($Checkbox11)
    $flag12 = GUICtrlRead($Checkbox12)
    $flag13 = GUICtrlRead($Checkbox13)
    $flag14 = GUICtrlRead($Checkbox14)
    $flag15 = GUICtrlRead($Checkbox15)
    $flag16 = GUICtrlRead($Checkbox16)
    $flag17 = GUICtrlRead($Checkbox17)
    $flag18 = GUICtrlRead($Checkbox18)
    $flag19 = GUICtrlRead($Checkbox19)
    $flag20 = GUICtrlRead($Checkbox20)
    $flag21 = GUICtrlRead($Checkbox21)
    $flag22 = GUICtrlRead($Checkbox22)
    $flag23 = GUICtrlRead($Checkbox23)
    $flag24 = GUICtrlRead($Checkbox24)
    $flag25 = GUICtrlRead($Checkbox25)
    $flag26 = GUICtrlRead($Checkbox26)
    $flag27 = GUICtrlRead($Checkbox27)
    $flag28 = GUICtrlRead($Checkbox28)
    $flag29 = GUICtrlRead($Checkbox29)
    $flag30 = GUICtrlRead($Checkbox30)
    $flag31 = GUICtrlRead($Checkbox31)
    $flag32 = GUICtrlRead($Checkbox32)
    $flag33 = GUICtrlRead($Checkbox33)
    $flag34 = GUICtrlRead($Checkbox34)
    $flag35 = GUICtrlRead($Checkbox35)
    $user = GUICtrlRead($Input1)
    $pass = GUICtrlRead($Input2)

EndFunc   ;==>_legge_ceckbox


Func _memoria_impostazioni()

    Local $iDelete = FileDelete($sFilePath)
    If $iDelete = -1 Then
        MsgBox($MB_SYSTEMMODAL, "Info", "Errore non c'è il File di configurazione da cancellare")
        Return False
    EndIf

    _legge_ceckbox()

    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWrite($hFileOpen, $flag1 & @CRLF)
    FileWrite($hFileOpen, $flag2 & @CRLF)
    FileWrite($hFileOpen, $flag3 & @CRLF)
    FileWrite($hFileOpen, $flag4 & @CRLF)
    FileWrite($hFileOpen, $flag5 & @CRLF)
    FileWrite($hFileOpen, $flag6 & @CRLF)
    FileWrite($hFileOpen, $flag7 & @CRLF)
    FileWrite($hFileOpen, $flag8 & @CRLF)
    FileWrite($hFileOpen, $flag9 & @CRLF)
    FileWrite($hFileOpen, $flag10 & @CRLF)
    FileWrite($hFileOpen, $flag11 & @CRLF)
    FileWrite($hFileOpen, $flag12 & @CRLF)
    FileWrite($hFileOpen, $flag13 & @CRLF)
    FileWrite($hFileOpen, $flag14 & @CRLF)
    FileWrite($hFileOpen, $flag15 & @CRLF)
    FileWrite($hFileOpen, $flag16 & @CRLF)
    FileWrite($hFileOpen, $flag17 & @CRLF)
    FileWrite($hFileOpen, $flag18 & @CRLF)
    FileWrite($hFileOpen, $flag19 & @CRLF)
    FileWrite($hFileOpen, $flag20 & @CRLF)
    FileWrite($hFileOpen, $flag21 & @CRLF)
    FileWrite($hFileOpen, $flag22 & @CRLF)
    FileWrite($hFileOpen, $flag23 & @CRLF)
    FileWrite($hFileOpen, $flag24 & @CRLF)
    FileWrite($hFileOpen, $flag25 & @CRLF)
    FileWrite($hFileOpen, $flag26 & @CRLF)
    FileWrite($hFileOpen, $flag27 & @CRLF)
    FileWrite($hFileOpen, $flag28 & @CRLF)
    FileWrite($hFileOpen, $flag29 & @CRLF)
    FileWrite($hFileOpen, $flag30 & @CRLF)
    FileWrite($hFileOpen, $flag31 & @CRLF)
    FileWrite($hFileOpen, $flag32 & @CRLF)
    FileWrite($hFileOpen, $flag33 & @CRLF)
    FileWrite($hFileOpen, $flag34 & @CRLF)
    FileWrite($hFileOpen, $flag35 & @CRLF)
    FileWrite($hFileOpen, $user & @CRLF)
    FileWrite($hFileOpen, $pass & @CRLF)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)


EndFunc   ;==>_memoria_impostazioni


Func _Tutti_select()
    Local $tutti_flag = GUICtrlRead($Checkbox35)

    If $tutti_flag = 1 Then

        GUICtrlSetState($Checkbox1, $GUI_CHECKED)
        GUICtrlSetState($Checkbox2, $GUI_CHECKED)
        GUICtrlSetState($Checkbox3, $GUI_CHECKED)
        GUICtrlSetState($Checkbox4, $GUI_CHECKED)
        GUICtrlSetState($Checkbox5, $GUI_CHECKED)
        GUICtrlSetState($Checkbox6, $GUI_CHECKED)
        GUICtrlSetState($Checkbox7, $GUI_CHECKED)
        GUICtrlSetState($Checkbox8, $GUI_CHECKED)
        GUICtrlSetState($Checkbox9, $GUI_CHECKED)
        GUICtrlSetState($Checkbox10, $GUI_CHECKED)
        GUICtrlSetState($Checkbox11, $GUI_CHECKED)
        GUICtrlSetState($Checkbox12, $GUI_CHECKED)
        GUICtrlSetState($Checkbox13, $GUI_CHECKED)
        GUICtrlSetState($Checkbox14, $GUI_CHECKED)
        GUICtrlSetState($Checkbox15, $GUI_CHECKED)
        GUICtrlSetState($Checkbox16, $GUI_CHECKED)
        GUICtrlSetState($Checkbox17, $GUI_CHECKED)
        GUICtrlSetState($Checkbox18, $GUI_CHECKED)
        GUICtrlSetState($Checkbox19, $GUI_CHECKED)
        GUICtrlSetState($Checkbox20, $GUI_CHECKED)
        GUICtrlSetState($Checkbox21, $GUI_CHECKED)
        GUICtrlSetState($Checkbox23, $GUI_CHECKED)
        GUICtrlSetState($Checkbox24, $GUI_CHECKED)
        GUICtrlSetState($Checkbox25, $GUI_CHECKED)
        GUICtrlSetState($Checkbox26, $GUI_CHECKED)
        GUICtrlSetState($Checkbox22, $GUI_CHECKED)
        GUICtrlSetState($Checkbox27, $GUI_CHECKED)
        GUICtrlSetState($Checkbox28, $GUI_CHECKED)
        GUICtrlSetState($Checkbox29, $GUI_CHECKED)
        GUICtrlSetState($Checkbox30, $GUI_CHECKED)
        GUICtrlSetState($Checkbox31, $GUI_CHECKED)
        GUICtrlSetState($Checkbox32, $GUI_CHECKED)
        GUICtrlSetState($Checkbox33, $GUI_CHECKED)
        GUICtrlSetState($Checkbox34, $GUI_CHECKED)
        GUICtrlSetState($Checkbox35, $GUI_CHECKED)


    Else

        GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox5, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox6, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox7, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox8, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox9, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox10, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox11, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox12, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox13, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox14, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox15, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox16, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox17, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox18, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox19, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox20, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox21, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox23, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox24, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox25, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox26, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox22, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox27, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox28, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox29, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox30, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox31, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox32, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox33, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox34, $GUI_UNCHECKED)
        GUICtrlSetState($Checkbox35, $GUI_UNCHECKED)


    EndIf

    ;MsgBox (0,'',$tutti_flag)


EndFunc   ;==>_Tutti_select








Func _morto_del_mese()

    ShellExecute("www1.ilmortodelmese.com")
    If @error Then MsgBox($MB_ICONERROR, 'ERROR', 'Errore inaspettato !!')

EndFunc   ;==>_morto_del_mese


Func _sound()

    _IECreate("https://www.youtube.com/watch?v=vifsqv_QXB0", 1, 0, 0)

EndFunc   ;==>_sound


Func _close()
    _memoria_impostazioni()

    Exit

EndFunc   ;==>_close

;===============================================================

;Keep the GUI alive

;===============================================================

While 1

    Sleep(1000)

WEnd


Func _stop() ; chiudo il file  che grabba
    ProcessClose($iPID)
EndFunc   ;==>_stop

and  this is a  server

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "192.168.1.106" ; This IP Address only works for testing on your own computer.
    Local $iPort = 5432 ; Port used for the connection.

    #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)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "tata" to the server.
    TCPSend($iSocket, "tata")

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

Func MyTCP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0

    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to be used by the Client socket.
    Local $iSocket = 0

    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        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 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    ; Assign a Local variable the data received.
    Local $sReceived = TCPRecv($iSocket, 4) ;we're waiting for the string "tata" OR "toto" (example script TCPRecv): 4 bytes length.

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Server

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

 

Link to comment
Share on other sites

;Defines Starting and Ending IP to scan through.
$StartIP = "192.168.0.2"
$EndIP = "192.168.0.255"

;Get IP Range
$StartIPArray = StringSplit($StartIP, ".", 2) ;This splits the ip into 4 segments so we can do work on it. Option 2 disables the count on $Array[0] and since this is always going to be 4 segments, we don't need to keep count.
$EndIPArray = StringSplit($EndIP, ".", 2) ;Same as above
$StartIPRange = $StartIPArray[3] ;Arrays start at 0, so this is the 4th segment containing the range.
$EndIPRange = $EndIPArray[3] ;Same as above.

;Do work on IP Range
For $i = $StartIPRange To $EndIPRange ;loops until the entire range has been checked.
    MsgBox(0, "IP Address", "Checking IP " & $StartIPArray[0] & "." & $StartIPArray[1] & "." & $StartIPArray[2] & "." & $I);you should replace this with a function that actually does what you need.
Next ;increments $i by one ($i+=1) and Continues loop (ContinueLoop).

Hard to understand what you are asking for because your english isn't very good, but I think I understand what you need.

 

 

Link to comment
Share on other sites

yea sorry for  my bad  english , :) (usally in the  night  after  working  day is  so hard  think in english :D ) ..so..

i try to explain much better  what  i want  do.

i  take  by input  box  a  ip start (example 192.168.1.1) and ip end (ex. 192.168.1.254)

i did  do  whit  this part of  code:

Local $IP_Start = GUICtrlRead($Input3)
    Local $IP_End = GUICtrlRead($Input4)
    Local $z = 0
    Local $Range = $IP_Adrss[1] & "." & $IP_Adrss[2] & "." & $IP_Adrss[3] & "."
    Local $Address[$IP_End]

after this  i want  controll if  in my net  is open  the  port  3356

i did do  with this  part of  code:

TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")



    For $i = $IP_Start To ($IP_End)


        $Address[$z] = $Range & $i

          $iSocket = TCPConnect( $Address[$z], $IP_Port)
        ;$iSocket = TCPConnect("192.168.1.106", 3356)
        Local $iError = 0

        ; If an error occurred display the error code and return False.
        If @error Then
            ; The server is probably offline/port is not opened on the server.
            ;$iError = @error
            ;MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
            ;Return False
        Else
            MsgBox(0, '', 'connessione avveuta')
        EndIf

        $z += 1
    Next
    _ArrayDisplay($Address)
    Local $aArrayUnique = _ArrayUnique($Address) ; Use default parameters to create a unique array.
    _ArrayDisplay($aArrayUnique, "$aArray Unique")
    ; Close the socket.
    TCPCloseSocket($iSocket)

    _Display()

i notice  , if  insert directly  a  opened  machine  $iSocket = TCPConnect("192.168.1.106", 3356),  work  good 

but  if  i  use  this code   $iSocket = TCPConnect( $Address[$z], $IP_Port)  , not  work , i have  always  error , also when  arrive at 106

why ???

 

 

 

Edited by faustf
Link to comment
Share on other sites

I think I found the issue. On your client, your code looks like this:

$IP_Adrss = StringSplit(@IPAddress1, '.')

    $Label3 = GUICtrlCreateLabel($IP_Adrss[1] & '.' & $IP_Adrss[2] & '.' & $IP_Adrss[3], 16, 580, 52, 17)
    GUICtrlSetState($Label3, $GUI_DISABLE)
    $Label4 = GUICtrlCreateLabel($IP_Adrss[1] & '.' & $IP_Adrss[2] & '.' & $IP_Adrss[3], 16, 613, 51, 17)

and

Local $Range = $IP_Adrss[1] & "." & $IP_Adrss[2] & "." & $IP_Adrss[3] & "."

 

In the first bit of code, you neglected to add ↓ after $IP_Adrss[3] as you did in the second bit of code ↑

& "."

My theory is you are typing this period into the input box instead of letting the script handle it for you. As such, I believe you have 2 period between segment 3 and 4

192.168.0..2

Try changing the first bit of code ↑ to the code ↓

$IP_Adrss = StringSplit(@IPAddress1, '.')

    $Label3 = GUICtrlCreateLabel($IP_Adrss[1] & '.' & $IP_Adrss[2] & '.' & $IP_Adrss[3] & ".", 16, 580, 52, 17)
    GUICtrlSetState($Label3, $GUI_DISABLE)
    $Label4 = GUICtrlCreateLabel($IP_Adrss[1] & '.' & $IP_Adrss[2] & '.' & $IP_Adrss[3] & ".", 16, 613, 51, 17)

 

 

 

Link to comment
Share on other sites

i dont  change  nothing  only  insert  a  consolewrite 

 

ConsoleWrite ( $Address[$z]& @CRLF)

now  working   :blink::blink:

 

and  i  verify if  have  this  error

192.168.0..2

but  i  writed  correct  :)

 

thankz  at  all  :)  for  support 

 

Link to comment
Share on other sites

Have you tried it using a _GUICtrlIpAddress_Create control to do the IP address part?

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Get (String) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    $hButton = GUICtrlCreateButton("Get Address", 30, 50)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, @IPAddress1)

    ; Wait for user to close GUI
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hButton
                MsgBox($MB_SYSTEMMODAL, "Information", "IP Address: " & _GUICtrlIpAddress_Get($hIPAddress))
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

 

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...