AHKsock - A simple AHK implementation of Winsock (TCP/IP)
ie: telnet into a site and refresh a gui with the stream it produces !
cheers :?
TheGood: Great Stuff! I can see this being really useful for AHK users for as long as AHK is still used.
I have one suggestion, and in the same stream as Franzk's question. I'd be lost without the StreamProcessor you included in your Example #3. Would you consider including a general version of that function in the library? I believe this would greatly ease script-to-script communication because strings are the native variable for all AHK scripts.
If I may suggest a possible syntax...
R := AHKsock_StreamProcessor(Socket, bNewData, bNewDataLength) if (R = "") { ; Stream is still processing, no string to output yet } else { Msgbox Received complete string: %R% }To keep it straight with other sockets, SP would need to use %Socket% in the name of its static variables
(Also maybe include AHKsock_StreamProcessor(Socket) in the recv() 'disconnect' routine to automatically clear the buffer for that socket?)
And complementing it with a new function for the sender's side...
AHKsock_StreamSend(Socket, StringVar) { ; Send StringLength Frame ; Send String }
Whaddaya think? I can put in some work on these later on if you think these features would jive well with your ideas for the library.
Call to non-existent function
Specifically: Anchor(htxtDialog,"wh")
Line 105.
?? any ideas ?
eg: HELO mail.microsoft.com -> popup msgbox..
Thanks :?
Whether or not AHKsock is the answer to your specific problem with your mailbox, I don't know.
If anyone can help I'd be very grateful 8)
Hey franzk. This is much more complicated than that. Like I said before, AHKsock only takes care of interacting with the transport layer and under. But the application layer is all up to you. AHKsock does not "speak" any protocol in that layer (like HTTP, FTP, and TelNet). It is up to you to take care of the application layer protocol, either by making up your own, or by abiding to a well-known protocol (which is hard since you would need to have deep knowledge of the protocol). For example, in Example 3, I made up my own kind of protocol (which uses different types of frames). Look into it for more info.All I want to do is watch my mail server port 25 and if key words appear in the streaming output perform an action.
eg: HELO mail.microsoft.com -> popup msgbox..
Thanks :?
I hope this helps!
Hi Mr Elmo,I have one suggestion, and in the same stream as Franzk's question. I'd be lost without the StreamProcessor you included in your Example #3. Would you consider including a general version of that function in the library? I believe this would greatly ease script-to-script communication because strings are the native variable for all AHK scripts.
Why not just copy my StreamProcessor() function into your script and adapt it to your needs? That's what I built it for!
In reality, I did think about doing what you suggested, but decided against it simply because it is not something that all applications need. As you can see, Example 1 and Example 2 do not use any stream processing function (although Example 2 does have a simplified version of a stream processor).
It would also be restraining if the user uses delimiting (ie. consider all the data between two delimiters as one frame) instead of length-prefixing (as used in the SP function) to "create" frames.
More generally, applications that do not communicate in a frame-like manner could dispense of the StreamProcessor() for maximum efficiency. It makes more sense to have it part of the user script, because it will always need to be adapted to fit the application's requirements.
Hope this helps!
Edit: I also added Anchor() into Example 3.
Any plans to add Unicode support for AutoHotkey_L?
Thanks!Great work, it looks really promising
Working on it as we speak!Any plans to add Unicode support for AutoHotkey_L?
Almost done in fact.
Thank you very muchAdded AHK_L x86/x64 Unicode support!
As I describe in this thread, I'm very interested in getting an AHK client to be able to talk to a server running PHP. I chose PHP because it is very similar to AHK, incredibly easy to use and learn, and has a well supported built in library for Berkeley sockets. In particular, I suspect that the functions available in the PHP Socket Functions library are probably close analogues to the functions available in the Winsock library or other Berkeley Sockets based libraries. Plus, it's quite easy to download PHP for windows or even XAMPP,
Any tips on how I might go about making a PHP server to talk with your AHK library? This is probably a long shot, but any chance that you might be willing to write up some example pseudo code, just describing which functions I should call and what sort of inputs I should send to those functions?
Thanks! I'm happy to know you got something out of it.Just discovered this library. [...]
Sure. There's nothing stopping you from writing the server in PHP and the client in AHK. If you're the one making both, then it's just a matter of making sure you're using the same protocol (which you will have to invent).As I describe in this thread, I'm very interested in getting an AHK client to be able to talk to a server running PHP.
For example, in my chatting scripts, my "protocol" was to use typing update frames and string length frames to communicate. As long as this basic system is obeyed, the client/server could have been written in any language supporting WinSock.
Any tips on how I might go about making a PHP server to talk with your AHK library?
Unfortunately, I do not have any experience with PHP, but it should be pretty straight-forward. You would use AHKsock_Connect to connect to the PHP server, and then, assuming it's the PHP server that starts sending data, you would intercept the RECEIVED event and treat it as necessary. In the opposite case, if the AHK client is the one that starts sending data, you would send data either in the SEND event using AHKsock_Send or outside the funciton using AHKsock_ForceSend.This is probably a long shot, but any chance that you might be willing to write up some example pseudo code, just describing which functions I should call and what sort of inputs I should send to those functions?
AHKsock_Connect(MyPHPServer, Port, "Function") Return Function(sEvent, iSocket = 0, sName = 0, sAddr = 0, sPort = 0, ByRef bData = 0, bDataLength = 0) { If (sEvent = "RECEIVED") ;You received data from the PHP server. Do what you need to do, i.e. save it to a file, display information, etc... Else If (sEvent = "SEND") ;You are clear for sending data to the PHP server, if any. AHKsock_Send(iSocket, &MyData, MyDataLength) ;You can also use AHKsock_ForceSend() instead outside of the function. (See docs and examples...) }
I know this is very general, but all you really need to do is simply to follow the same protocol on both sides.