Ranmaru Posted November 15, 2007 Share Posted November 15, 2007 Is it possible to make TCPRecv trigger an event? I think having to manually check for new TCP messages with TCPRecv is a bad method... And there are events for AutoIt for tray and gui controls, so why not TCP or have I just not found these? - Thanks for any info, Ran. Link to comment Share on other sites More sharing options...
NELyon Posted November 15, 2007 Share Posted November 15, 2007 You mean something like this? ;Put your other code before this While 1 If TCPRecv($conn) Then If TCPRecv($conn) = "exit" Then Exit EndIf EndIf WEnd If this is not what you mean, PM me. I'll show you one of my old codes that might help you. Link to comment Share on other sites More sharing options...
Ranmaru Posted November 15, 2007 Author Share Posted November 15, 2007 (edited) You mean something like this? ;Put your other code before this While 1 If TCPRecv($conn) Then If TCPRecv($conn) = "exit" Then Exit EndIf EndIf WEnd If this is not what you mean, PM me. I'll show you one of my old codes that might help you. No this is manual checking.. Like I said I'm looking for an EVENT. A function that is automatically triggered when receiving messages so the script doesn't have to keep on listening to them and can do something else instead. Functions similiar to those of tray and gui controls.. GUICtrlSetOnEvent($hwnd, "function_name") TrayCtrlSetOnEvent($hwnd, "function_name") Not sure if those are the right functions to use, then there's the Opt that has to be set first. I don't have ScITE open atm so nevermind if I didn't get them right, you know what I mean. Edited November 15, 2007 by Ranmaru Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 15, 2007 Share Posted November 15, 2007 I doubt it will happen. Socket programming doesn't use events, it just uses buffers in every instance I have seen. You can pick up data, or you can let it pile up, but you have to read it yourself. Link to comment Share on other sites More sharing options...
Ranmaru Posted November 15, 2007 Author Share Posted November 15, 2007 (edited) I doubt it will happen. Socket programming doesn't use events, it just uses buffers in every instance I have seen. You can pick up data, or you can let it pile up, but you have to read it yourself.Events are used for ActionScript's XMLSockets (Basically these are just TCP sockets) that is used in Flash, works like a charm there./EDIT:Your TCP messages sent using the XMLSockets are all in HEX and each message is terminated with the NULL char so that's how it knows when a message is complete, quite nice system they have. There could be a similiar option for AutoIt so you could manually set the terminating character. Edited November 15, 2007 by Ranmaru Link to comment Share on other sites More sharing options...
AzKay Posted November 16, 2007 Share Posted November 16, 2007 Could also use adlibenable; #include <String.au3> TCPStartup() $oSock = TCPConnect("", ) AdlibEnable("Recv", 1) TCPSend($oSock, Hexit("")) While 1 Sleep(100) WEnd Func Recv() $oRecv = TCPRecv($oSock, 2045) If $oRecv <> "" Then ConsoleWrite($oRecv) EndIf EndFunc Func Hexit($oText) Return _HexToString(StringReplace($oText, " ", "")) EndFunc Thats what I use, But yeah, Not what you want. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
ptrex Posted November 16, 2007 Share Posted November 16, 2007 @allThe "AdlibEnable" is more or less the same as a While / Next loop with a sleep (250) in it.The better way is to use the Socket Events from Windows :Like this Socket EventsBut unfortunately you will have to do through the DLLCall API's. It is not build into AU3.regardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted November 16, 2007 Share Posted November 16, 2007 Zatorg posted this awhile back, I've been playing with it forever, and I love it. I'm making an old school MUD server with it currently, but it will work with anything.Asynchronous sockets UDF Link to comment Share on other sites More sharing options...
ptrex Posted November 16, 2007 Share Posted November 16, 2007 @SkinnyWhiteGuy PERFECT !!! Thanks for digging it up, I must have missed that. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Ranmaru Posted November 16, 2007 Author Share Posted November 16, 2007 @allThe "AdlibEnable" is more or less the same as a While / Next loop with a sleep (250) in it.The better way is to use the Socket Events from Windows :Like this Socket EventsBut unfortunately you will have to do through the DLLCall API's. It is not build into AU3.regardsptrexSeems interesting I will probably take some time to get into this too later, thanks ptrex.Zatorg posted this awhile back, I've been playing with it forever, and I love it. I'm making an old school MUD server with it currently, but it will work with anything.Asynchronous sockets UDFThis is most usefull, thanks SkinnyWhiteGuy. 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