Der_Andi Posted April 11, 2007 Share Posted April 11, 2007 Hi, first i start the listen-script: TCPStartup() $socket = TCPListen(@IPAddress1, 33333) Do $conn = TCPAccept($socket) Sleep(500) Until $conn <> -1 Do $recv = TCPRecv($socket, 512) Sleep(1000) Until $recv <> "" MsgBox(0, "", $recv) oÝ÷ Ø2¢çÇקvÌ!zv¬¶¸§++yÇ¢½çp'!Éèµé§$ázz-zjmÊËkx"²Ç§µ¼ëÛ®*mjëh×6 Opt("OnExitFunc", "_quit") TCPStartup() $socket = TCPConnect(@IPAddress1, 33333) Sleep(2000) Exit Func _quit() ;defined as OnExitFunc TCPSend($socket, "bye") TCPShutdown() EndFunc The "bye" is not being sent. I'm testing these scripts on one computer. Some ideas? After 30 minutes, i gave up... Link to comment Share on other sites More sharing options...
MrCreatoR Posted April 11, 2007 Share Posted April 11, 2007 If you want to check if the function is executed, just out MsgBox at start of that function, and you will see if this function is started when exit, if so, then the problem is in TCPSend($socket, "bye"). Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
jvanegmond Posted April 11, 2007 Share Posted April 11, 2007 (edited) TCPStartup() Dim $ConnectedSocket = -1 $Socket = TCPListen(@IPAddress1,33333) While 1 $NewSocket = TCPAccept($Socket) If $NewSocket >= 0 Then $ConnectedSocket = $NewSocket EndIf If $ConnectedSocket <> -1 Then $Data = TCPRecv($ConnectedSocket,1024) If $Data <> "" Then ConsoleWrite($Data) EndIf WEndoÝ÷ Ù8Z¶+0«Hjk¬x-¡Æ©¶êÞu«ZJÚÚ¥ÊØ^ìmn+]¡ë'¢Ü(®G¢¶«ß}÷lGb·öå¢[hu¬¢µÚ±¹bDájܲËkjxjëh×6TCPStartup() $socket = TCPConnect(@IPAddress1, 33333) TCPSend($socket,"test data" & @CRLF) Sleep(2000) _quit() Exit Func _quit() ;defined as OnExitFunc TCPSend($socket,"bye") TCPShutdown() EndFuncoÝ÷ Ù»¶¬v¬jëh×6TCPStartup() $socket = TCPConnect(@IPAddress1, 33333) TCPSend($socket,"test data" & @CRLF) Sleep(2000) TCPSend($socket,"bye") TCPShutdown() Exit Edited April 12, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
martin Posted April 11, 2007 Share Posted April 11, 2007 TCPStartup() Dim $ConnectedSocket = -1 $Socket = TCPListen(@IPAddress1,33333) While 1 $NewSocket = TCPAccept($Socket) If $NewSocket >= 0 Then $ConnectedSocket = $NewSocket EndIf If $ConnectedSocket <> -1 Then $Data = TCPRecv($ConnectedSocket,1024) If $Data <> "" Then ConsoleWrite($Data) EndIf WEndoÝ÷ Ù8Z¶+0«Hjk¬x-¡Æ©¶êÞu«ZJÚÚ¥ÊØ^ìmn+]¡ë'¢Ü(®G¢¶«ß}÷jëh×6TCPStartup() $socket = TCPConnect(@IPAddress1, 33333) TCPSend($socket,"test data" & @CRLF) Sleep(2000) _quit() Exit Func _quit() ;defined as OnExitFunc TCPSend($socket,"bye") TCPShutdown() EndFuncoÝ÷ Ù»¶¬v¬jëh×6TCPStartup() $socket = TCPConnect(@IPAddress1, 33333) TCPSend($socket,"test data" & @CRLF) Sleep(2000) TCPSend($socket,"bye") TCPShutdown() Exit What happens if you use 127.0.0.1 for the ip address instead of @IPAddress1? 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. Link to comment Share on other sites More sharing options...
Der_Andi Posted April 11, 2007 Author Share Posted April 11, 2007 What happens if you use 127.0.0.1 for the ip address instead of @IPAddress1?The same: nothing.@MsCreatoR:A MsgBox in the OnAutoItExit-Function is executed. But not the TCPSend(). This is either strange or a bug! Background: I want to create a client-like script that would run on a remote computer. When this computer goes down, the script sends a bye-message to the server-script on my computer. I also had the idea to work with a keep-alive-signal. Every x seconds the client sends a signal. If the remote computer goes down, no more signal can be sent. Link to comment Share on other sites More sharing options...
MHz Posted April 12, 2007 Share Posted April 12, 2007 (edited) The "bye" is not being sent.I'm testing these scripts on one computer.Some ideas? After 30 minutes, i gave up... Your script cannot continue into the OnAutoitExit function because your script has exited upon calling the OnAutoitExit function. You will still have use of the variables as they are still in memory and you can now use the @exitmethod as well as the @exitcode macro's. The OnAutoitExit function is for cleanup and not for continuation of code from the main script. Edited April 12, 2007 by MHz Link to comment Share on other sites More sharing options...
Der_Andi Posted April 12, 2007 Author Share Posted April 12, 2007 (edited) ...because your script has exited ...That sounds logical. I thought, the OnAutoItExit-Function is executed before the actual Exit. Edited April 12, 2007 by Der_Andi Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now