well this is my first public contribution to the forums
This is a UDF library providing functions for using asynchronous sockets (and async socket transfer).
An asynchronous socket is a socket with which you can listen(), connect(), send() and recv() asynchronously, that is, while the Windows Sockets implementation (Winsock) attempts to complete your action, your program is doing other stuff. When the action is completed (or has afailed) your program is given a notification. In AutoIt3, you GUIRegisterMsg( $iYourMessageID, $sTheFunctionToCall ) and then do whatever you want to (poll the GUI for events, perform calculations etc.) and have the function called when an event that interests you occurs.
///
EDIT: warning: a lot of yada yada follows beyond this!
If you want to see the effect and read some pretty simple and commented sources just go to this post.
///
This is rather simple. Take a look at this:
This is an example server that uses async sockets. It waits for incoming connections and handles them. At the same time, it does usesless bullshit that you can change to useful work like GUI handling or so.
<removed, download from this post>
This is an example client that uses async sockets. It's crazy because it attempts to connect to one place a few times thus establishing a few simultaneous connections. But that's just what we need since my goal is to prove the simplicity of synchronizing socket transfer and program's normal flow whatsoever.
<removed, download from this post>
<Obsolete>
I'm too damn lazy to write a client now... If this gains interest (or I'm at 3A.M. by the computer one night) I'll write one... At present, use one of those blocking TCP clients or use this one. It's a piece of crap, from the days when I was scripting in AutoIt only, and it's not finished. And, oh, it's in lithuanian
"prisij hostname_or_IP:port" connects to a host. Use this to test the async server.
"atsij hostname_or_IP:port" disconnects from a host.
Edit: forgot to mention that any other text that is entered is sent to all the connected peers. This way you can see how async server gets notified about received data.
It's an old and crappy server+client (I know it's childish). It uses blocking sockets and shouldn't be used unless you can't find a simple client to test the server...
CNCServ.au3 9.71K
900 downloads</Obsolete>Well basically this is it. Here is the UDF:
ASock.au3 5.09K
1780 downloadsOK it's a very long post I have here. If anyone reads it fully, congrats!
Anyway, any comments, criticism, ideas and feedback are eagerly waited. If you find this useful or a piece of crap, please let me know.
Cheers
Kostas
EDIT: See my next post to get more info about the _ASock functions.
EDIT #2: this is the same async server that instead of doing nothing while Winsock is polling for data and such, it sends large chunks of data. This version shows that TCPSend() returns immediately even after being requested to send a lot of data if used with async sockets.
server_.au3 7.03K
821 downloadsEDIT #3: Posted an example client. It's the same server with some stuff changed.
EDIT #4: Added a really simple server example.
OK I guess that I haven't got the ability to explain easily...
Happy coding!
Edited by Jon, 24 July 2009 - 07:24 AM.





