Sign in to follow this  
Followers 0
Targus

[Solved]TCP Or UDP Server Detection

7 posts in this topic

#1 ·  Posted (edited)

ok so atm i have set up a gui to have a button that will call a function called _Detection now what im planing to do is have that function do the following

Send Data To : <Ip> at <Port> to 3 diff servers all have the same ip but diff port and then i need to set a value to OFF if it fails and ON if it works but ive looked at TCP / UDP Send Listen Connect and tryed them but im not sure on how to use them XD

::: Normal Load

Splash Screen Want The Program To Detect the servers while this is up and that is already set just needa know how to do this

after that the screen goes away

Main GUI Starts And Words / buttons Load bla bla

Another Note is it possible to have the splash grab a html image ?

and can u do Run(<name>) as a non pop up aka if ur in a fullscreen u alt tab to it anyway to disable that XD

Heres The code if needed

and yes this is for a online game the one im using now is anyoing

Global $Charstats, $loginstats, $Worldstats ;==> Server Stats
Global $Group1, $Form1, $Label1 ;==> GUI Setup
Global $WChar, $WLogin, $WWorld ;==> GUI Words For Servers
Global $DChar, $DLogin, $DWorld ;==> GUI Words Detection Information
global $SChar, $SLogin, $SWorld ;==> Stats For Servers
global $Start, $Status, $Close, $Restart ;==> Buttons
global $GroupButtons, $GroupInfo ;==> Groups
$prefsitem = TrayCreateItem("Made By")
$aboutitem = TrayCreateItem("Kris")
$aboutitem1 = TrayCreateItem("Flyff Life Server Host ")
func _Restart()
    GUISetState(@SW_DISABLE)
    ProcessClose("3. World Server.exe")
    sleep (1000)
    ProcessClose("2. Char Server.exe")
    sleep (1000)
    ProcessClose("1. Login Server.exe")
    sleep (1000)
    Run("1. Login Server.exe")
    sleep (1000)
    Run("2. Char Server.exe")
    sleep (1000)
    Run("3. World Server.exe")
    sleep (1000)
    GUISetState(@SW_ENABLE) 
EndFunc

func _Start()
    GUISetState(@SW_DISABLE)
    Run("1. Login Server.exe")
    sleep (1000)
    Run("2. Char Server.exe")
    sleep (1000)
    Run("3. World Server.exe")
    sleep (1000)    
    GUISetState(@SW_ENABLE)
EndFunc

func _Stop()
    GUISetState(@SW_DISABLE)
    ProcessClose("3. World Server.exe")
    sleep (1000)
    ProcessClose("2. Char Server.exe")
    sleep (1000)
    ProcessClose("1. Login Server.exe")
    sleep (1000)    
    GUISetState(@SW_ENABLE)
EndFunc



func _Splash()
#Region --- CodeWizard generated code Start ---
;SpashImage features: Title=No, Width=754, Height=137 Start Up Image
SplashImageOn("","C:\Documents and Settings\Kris\Desktop\newbanner.jpg","754","137","-1","-1",3)
sleep(1000)
SplashOff()
#EndRegion --- CodeWizard generated code End ---
endfunc 

Func _Detection()
    msgbox(1,"Error"," Not Complete")
;==>Need to Complete
EndFunc

func _SGUI()
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\kris\desktop\restarter project\restarter form.kxf
$Form1_1_1 = GUICreate("FlyFF Life", 256, 200, 360, 198)
$Label1 = GUICtrlCreateLabel("FlyFF Life Restarter Version 1.0", 8, 8, 237, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Bookman Old Style")
$GroupInfo = GUICtrlCreateGroup("Server Stats", 8, 32, 121, 89)
$WLogin = GUICtrlCreateLabel("Login Server :", 16, 56, 70, 17)
$WWorld = GUICtrlCreateLabel("World Server :", 16, 88, 72, 17)
$WChar = GUICtrlCreateLabel("Char Server :", 16, 72, 69, 17)
$SLogin = GUICtrlCreateLabel($Dlogin, 88, 56, 31, 17)
$SWorld = GUICtrlCreateLabel($DWorld, 88, 72, 36, 20)
$SChar = GUICtrlCreateLabel($DChar, 88, 88, 31, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupButtons = GUICtrlCreateGroup("Controls", 136, 32, 97, 137)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Start = GUICtrlCreateButton("Start Server", 144, 88, 83, 25)
$Server = GUICtrlCreateButton("Server Status", 144, 56, 83, 25)
$Close = GUICtrlCreateButton("Close Server", 144, 112, 83, 25)
$Restart = GUICtrlCreateButton("Restart Server", 144, 136, 83, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        case $Restart
            _Restart()
        case $Start
            _Start()
        case $Close
             _Stop()
        case $Server
             _Detection()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
EndFunc


_Main()

Func _Main()
    _Splash()
    _SGUI()
endfunc
Edited by Targus

Share this post


Link to post
Share on other sites



Read the TCPConnect() remarks and descriptions.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Edited The Edit:

ok so it sets the values to on if it works but how do i update them on the gui ?

everything to run it is in the code expect the splash but that doesn't matter

Global $Charstats, $loginstats, $Worldstats ;==> Server Stats
Global $Group1, $Form1, $Label1 ;==> GUI Setup
Global $WChar, $WLogin, $WWorld ;==> GUI Words For Servers
Global $DChar, $DLogin, $DWorld ;==> GUI Words Detection Information
global $SChar, $SLogin, $SWorld ;==> Stats For Servers
global $Start, $Status, $Close, $Restart ;==> Buttons
global $GroupButtons, $GroupInfo ;==> Groups
$prefsitem = TrayCreateItem("Made By")
$aboutitem = TrayCreateItem("Kris")
$aboutitem1 = TrayCreateItem("Flyff Life Server Host ")
func _Restart()
    GUISetState(@SW_DISABLE)
    ProcessClose("3. World Server.exe")
    sleep (1000)
    ProcessClose("2. Char Server.exe")
    sleep (1000)
    Run("2. Char Server.exe")
    sleep (1000)
    Run("3. World Server.exe")
    sleep (1000)
    GUISetState(@SW_ENABLE) 
EndFunc

func _Start()
    GUISetState(@SW_DISABLE)
    Run("1. Login Server.exe")
    sleep (1000)
    Run("2. Char Server.exe")
    sleep (1000)
    Run("3. World Server.exe")
    GUISetState(@SW_ENABLE)
EndFunc

func _Stop()
    GUISetState(@SW_DISABLE)
    ProcessClose("3. World Server.exe")
    sleep (1000)
    ProcessClose("2. Char Server.exe")
    sleep (3000)
    ProcessClose("1. Login Server.exe")
    GUISetState(@SW_ENABLE)
EndFunc



func _Splash()
#Region --- CodeWizard generated code Start ---
;SpashImage features: Title=No, Width=754, Height=137 Start Up Image
SplashImageOn("","C:\Documents and Settings\Kris\Desktop\newbanner.jpg","754","137","-1","-1",3)
sleep(1000)
SplashOff()
#EndRegion --- CodeWizard generated code End ---
endfunc 

Func _Detection()
GUISetState(@SW_DISABLE)
;==> Char
global $g_IPc, $socketc, $g_IP1c
$g_IPc = "flyfflife.game-host.org"
TCPStartUp()
$g_ip1c = TCPNameToIP ($g_IPc)
$socketc = TCPConnect( $g_IP1c, 28000 )
If $socketc = -1  Then 
    $DChar = "OFF"
else 
    $DChar = "ON"
endif ;==> Char

;==> Login
global $g_IPl, $socketl, $g_IP1l
$g_IPl = "flyfflife.game-host.org"
$g_ip1l = TCPNameToIP ($g_IPl)
$socketl = TCPConnect( $g_IP1l, 23000 )
If $socketl =  -1 Then 
    $Dlogin = "OFF"
else 
    $Dlogin = "ON"
endif ;==> Login


;==> World
global $g_IPw, $socketw, $g_IP1w
$g_IPw = "flyfflife.game-host.org"
$g_ip1w = TCPNameToIP ($g_IPw)
$socketw = TCPConnect( $g_IP1w, 15400 )
If $socketw = -1 Then 
    $DWorld = "OFF"
else 
    $DWorld = "ON"
endif ;==> World
msgbox(1,"", $socketw & "  " & $socketl & "  " & $socketc & "  " & $DWorld& "  " &$Dlogin& "  " &$DChar)
GUISetState(@SW_ENABLE)
GUISetState(@SW_SHOW)
TCPShutdown()
;==>Need to Complete
EndFunc

func _SGUI()
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\kris\desktop\restarter project\restarter form.kxf
$Form1_1_1 = GUICreate("FlyFF Life", 256, 200, 360, 198)
$Label1 = GUICtrlCreateLabel("FlyFF Life Restarter Version 1.0", 8, 8, 237, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Bookman Old Style")
$GroupInfo = GUICtrlCreateGroup("Server Stats", 8, 32, 121, 89)
$WLogin = GUICtrlCreateLabel("Login Server :", 16, 56, 70, 17)
$WWorld = GUICtrlCreateLabel("World Server :", 16, 88, 72, 17)
$WChar = GUICtrlCreateLabel("Char Server :", 16, 72, 69, 17)
$SLogin = GUICtrlCreateLabel("" & $Dlogin, 88, 56, 31, 17)
$SWorld = GUICtrlCreateLabel("" & $DWorld, 88, 72, 36, 20)
$SChar = GUICtrlCreateLabel("" & $DChar, 88, 88, 31, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupButtons = GUICtrlCreateGroup("Controls", 136, 32, 97, 137)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Start = GUICtrlCreateButton("Start Server", 144, 88, 83, 25)
$Server = GUICtrlCreateButton("Server Status", 144, 56, 83, 25)
$Close = GUICtrlCreateButton("Close Server", 144, 112, 83, 25)
$Restart = GUICtrlCreateButton("Restart Server", 144, 136, 83, 25)
GUISetState(@SW_SHOW)
_Detection()
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        case $Restart
            _Restart()
        case $Start
            _Start()
        case $Close
             _Stop()
        case $Server
             _Detection()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
EndFunc


_Main()

Func _Main()
    _Splash()
    _SGUI()
endfunc
Edited by Targus

Share this post


Link to post
Share on other sites

I think that what you're looking for is GuiCtrlSetData.

You have some neatly arranged code :)

It is better to put your include lines for standard au3 include files at the start of the script in the main body, ie not in functions. Admittedly the ones you have used do work in the function, but many includes will not because they have functions and you cannot have functions inside functions in AutoIt. Since the files which define constants generally define them as global then those files might as well be at the start of the script.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

ok so i looked at GuiCtrlSetData and i changed them a bit but i cant seem to get the gui to update.

im just wondering but did i do it wrong XD

Func _Detection()
GUISetState(@SW_DISABLE)
;==> Char
global $g_IPc, $socketc, $g_IP1c
$g_IPc = "flyfflife.game-host.org"
TCPStartUp()
$g_ip1c = TCPNameToIP ($g_IPc)
$socketc = TCPConnect( $g_IP1c, 28000 )
If $socketc = -1  Then 
    GuiCtrlSetData($DChar,"OFF")

else 
    GuiCtrlSetData($DChar,"ON")
endif ;==> Char

;==> Login
global $g_IPl, $socketl, $g_IP1l
$g_IPl = "flyfflife.game-host.org"
$g_ip1l = TCPNameToIP ($g_IPl)
$socketl = TCPConnect( $g_IP1l, 23000 )
If $socketl =  -1 Then 
    GuiCtrlSetData($DLogin,"OFF")

else 
    GuiCtrlSetData($DLogin,"ON")
endif ;==> Login


;==> World
global $g_IPw, $socketw, $g_IP1w
$g_IPw = "flyfflife.game-host.org"
$g_ip1w = TCPNameToIP ($g_IPw)
$socketw = TCPConnect( $g_IP1w, 15400 )
If $socketw = -1 Then 
    GuiCtrlSetData($DWorld,"OFF")

else 
    GuiCtrlSetData($DWorld,"ON")
endif ;==> World
msgbox(1,"", $socketw & "  " & $socketl & "  " & $socketc & "  " & $DWorld& "  " &$Dlogin& "  " &$DChar)
GUISetState(@SW_ENABLE)
GUISetState(@SW_SHOW)
TCPShutdown()
EndFunc

Share this post


Link to post
Share on other sites

According to your previous code, you're actually looking for:

$SLogin = GUICtrlCreateLabel("" & $Dlogin, 88, 56, 31, 17)
$SWorld = GUICtrlCreateLabel("" & $DWorld, 88, 72, 36, 20)
$SChar = GUICtrlCreateLabel("" & $DChar, 88, 88, 31, 17)oÝ÷ Ù*"¶ÈhºW[zX¤y«­¢+Ù%ÀÌØíͽ­ÑÜô´ÄQ¡¸(Õ¥
ÑɱMÑÑ ÀÌØíM]½É±°ÅÕ½Ðí=ÅÕ½Ðì¤()±Í(Õ¥
ÑɱMÑÑ ÀÌØíM]½É±°ÅÕ½Ðí=8ÅÕ½Ðì¤)¹¥ìôôÐì]½É±

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

yay works thanks for all ur help XD

Final Code With Thanks

Global $Charstats, $loginstats, $Worldstats ;==> Server Stats
Global $Group1, $Form1, $Label1 ;==> GUI Setup
Global $WChar, $WLogin, $WWorld ;==> GUI Words For Servers
Global $DChar, $DLogin, $DWorld ;==> GUI Words Detection Information
global $SChar, $SLogin, $SWorld ;==> Stats For Servers
global $Start, $Status, $Close, $Restart ;==> Buttons
global $GroupButtons, $GroupInfo ;==> Groups
global $Menu

Opt("TrayMenuMode", 1)

$Menu = TrayCreateMenu("Made By")
$aboutitem = TrayCreateItem("Kris",$Menu)
$aboutitem1 = TrayCreateItem("Flyff Life Server Host",$Menu)
$Menu = TrayCreateMenu("Debug / Help From")
$aboutitem14 = TrayCreateItem("Thanks Guys XD",$Menu)
$aboutitem11 = TrayCreateItem("Authenticity",$Menu)
$aboutitem12 = TrayCreateItem("martin",$Menu)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
func _Restart()
    GUISetState(@SW_DISABLE)
    ProcessClose("3. World Server.exe")
    sleep (1000)
    ProcessClose("2. Char Server.exe")
    sleep (1000)
    Run("2. Char Server.exe")
    sleep (1000)
    Run("3. World Server.exe")
    sleep (1000)
    GUISetState(@SW_ENABLE) 
EndFunc

func _Start()
    GUISetState(@SW_DISABLE)
    Run("1. Login Server.exe")
    sleep (1000)
    Run("2. Char Server.exe")
    sleep (1000)
    Run("3. World Server.exe")
    GUISetState(@SW_ENABLE)
EndFunc

func _Stop()
    GUISetState(@SW_DISABLE)
    ProcessClose("3. World Server.exe")
    sleep (1000)
    ProcessClose("2. Char Server.exe")
    sleep (3000)
    ProcessClose("1. Login Server.exe")
    GUISetState(@SW_ENABLE)
EndFunc



func _Splash()
#Region --- CodeWizard generated code Start ---
;SpashImage features: Title=No, Width=754, Height=137 Start Up Image
SplashImageOn("","C:\Documents and Settings\Kris\Desktop\newbanner.jpg","754","137","-1","-1",3)
sleep(1000)
SplashOff()
#EndRegion --- CodeWizard generated code End ---
endfunc 

Func _Detection()
GUISetState(@SW_DISABLE)
;==> Char
global $g_IPc, $socketc, $g_IP1c
$g_IPc = "flyfflife.game-host.org"
TCPStartUp()
$g_ip1c = TCPNameToIP ($g_IPc)
$socketc = TCPConnect( $g_IP1c, 28000 )
If $socketc = -1  Then 
    GuiCtrlSetData($sChar,"OFF")

else 
    GuiCtrlSetData($sChar,"ON")
endif ;==> Char

;==> Login
global $g_IPl, $socketl, $g_IP1l
$g_IPl = "flyfflife.game-host.org"
$g_ip1l = TCPNameToIP ($g_IPl)
$socketl = TCPConnect( $g_IP1l, 23000 )
If $socketl =  -1 Then 
    GuiCtrlSetData($sLogin,"OFF")

else 
    GuiCtrlSetData($sLogin,"ON")
endif ;==> Login


;==> World
global $g_IPw, $socketw, $g_IP1w
$g_IPw = "flyfflife.game-host.org"
$g_ip1w = TCPNameToIP ($g_IPw)
$socketw = TCPConnect( $g_IP1w, 15400 )
If $socketw = -1 Then 
    GuiCtrlSetData($sWorld,"OFF")

else 
    GuiCtrlSetData($sWorld,"ON")
endif ;==> World
msgbox(1,"", $socketw & "  " & $socketl & "  " & $socketc & "  " & $DWorld& "  " &$Dlogin& "  " &$DChar)
GUISetState(@SW_ENABLE)
GUISetState()
TCPShutdown()
EndFunc

func _SGUI()
#Region ### START Koda GUI section ### Form=c:\documents and settings\kris\desktop\restarter project\restarter form.kxf
$Form1_1_1 = GUICreate("FlyFF Life", 256, 200, 360, 198)
$Label1 = GUICtrlCreateLabel("FlyFF Life Restarter Version 1.0", 8, 8, 237, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Bookman Old Style")
$GroupInfo = GUICtrlCreateGroup("Server Stats", 8, 32, 121, 89)
$WLogin = GUICtrlCreateLabel("Login Server :", 16, 56, 70, 17)
$WWorld = GUICtrlCreateLabel("World Server :", 16, 88, 72, 17)
$WChar = GUICtrlCreateLabel("Char Server :", 16, 72, 69, 17)
$SLogin = GUICtrlCreateLabel("" & $Dlogin, 88, 56, 31, 17)
$SWorld = GUICtrlCreateLabel("" & $DWorld, 88, 72, 36, 20)
$SChar = GUICtrlCreateLabel("" & $DChar, 88, 88, 31, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupButtons = GUICtrlCreateGroup("Controls", 136, 32, 97, 137)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Start = GUICtrlCreateButton("Start Server", 144, 88, 83, 25)
$Server = GUICtrlCreateButton("Server Status", 144, 56, 83, 25)
$Close = GUICtrlCreateButton("Close Server", 144, 112, 83, 25)
$Restart = GUICtrlCreateButton("Restart Server", 144, 136, 83, 25)
GUISetState(@SW_SHOW)
_Detection()
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        case $Restart
            _Restart()
        case $Start
            _Start()
        case $Close
             _Stop()
        case $Server
             _Detection()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
EndFunc


_Main()

Func _Main()
    _Splash()
    _SGUI()
endfunc
Edited by Targus

Share this post


Link to post
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
Sign in to follow this  
Followers 0