Jump to content

How can I confirm TCPStartUp has started?


Recommended Posts

Hello, I'm trying my hand at a simple TCP server and client but I have a bit of a worry! I create a simple GUI to return the error code following the TCPStartUp command and its returning an error! I have tried using some example TCP Scripts too which don't seem to work properly. 

Would someone mind having a look at my code below and tell me if the TCPStartUp should be working? Should it be returning errorcode 1? 

And should my text steps be TCP Listen > TCP Accept > TCP Recieve?

I'm a bit of a noob so any help would be hugely appreciated :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('GUIonEventMode', 1)

$GUI = GUICreate("S.M.I Server", 472, 311, 751, 312)
$Content = GUICtrlCreateEdit("", 8, 8, 313, 289, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
GUISetState(@SW_SHOW)

GUICtrlSetData($Content, "Content")

TCPStartup()
IF @error == 1 Then
    GUICtrlSetData($content, "TCP Services started with: " & @Error)
Else
    GUICtrlSetData($content, "TCP Services failed with error: " & @error)
EndIf

While 1
        GUISetOnEvent($GUI_EVENT_CLOSE, "quit", $GUI)
WEnd

Func quit()
    TCPShutdown()
    GUICtrlSetData($content, "TCP Shut Down: " & @error)
    sleep(700)
    Exit
EndFunc

 

Link to comment
Share on other sites

try this:

; == Start the TCP service.

Example()

Func Example()
    Local $vTCP = TCPStartup() ; Start the TCP service.
    If $vTCP = 1 Then
        MsgBox(64, "", $vTCP)
    EndIf
EndFunc   ;==>Example

 

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

try this:

; == Start the TCP service.

Example()

Func Example()
    Local $vTCP = TCPStartup() ; Start the TCP service.
    If $vTCP = 1 Then
        MsgBox(64, "", $vTCP)
    EndIf
EndFunc   ;==>Example

 

​I assigned a variable to TCPStartUp() as you did and this returns the error code I'm now expecting within my GUI!  Thanks.

Next step is trying to get another script to talk to this one.

Link to comment
Share on other sites

You don't really need to hardcode the 1, If $vTCP Then is enough as anything that isn't zero is consider True, with zero meaning False. This is the beauty (or ugly side) of dynamic languages.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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

×
×
  • Create New...