Sign in to follow this  
Followers 0
rhg

AI Equivalent of Perl Expression $/="\0"

9 posts in this topic

Hi. I think AI3 is a great scripting platform and have been taking a real liking to it, especially the TCP/UDP functionality.

From all of the great contributions here on socket server implementation I thought I might try to setup a simple socket server to play with flash...not a "chat server"...although that is neat it has been done to death IMHO. I am actually looking for a different type of I/O functionality.

Flash uses the XMLSocket Object to connect to a socket server. I have successfully modified the server.au3 (Larry's orginal implementation [Thanks Larry]) and can successfully connect to it, and send messages from Flash to the socket server. My problem is getting them back to Flash.

Here is an exmaple of what I am doing/trying to do:

Flash sends: <vectorObj currentx="1" currenty="10" />

Server sends: <vectorObj newx="45" newy="200" />

Flash parses this message and applies the new incoming vector properties to a vector object...say placement of a rectangle on the stage and then moving the objects anchor to the new X/Y coordinates.

I know the flash movie works as I d/l'ed a 15 line Perl server script and verified it is working properly. Problem is I do not know hardly any perl at all as my background is batch/Basic/VBScript and some AS1/2, and the perl server is a chat implementation that just echo's whats incoming and forwards to all other connected clients vs what I am proposing. Plus I thought it would be fun to do in AutoIt, lol.

Soooo....after about a week of reading, trying, and failing, I finally found what I think is the problem:

Flash will listen and buffer incoming data until it receives an "empty byte" at which time it processes the incoming data. This empty byte is represented by $/="\0" in all the Perl/Python/Java examples I have found. So, what I have tried is to append that termination string from the $input box data, gathered in the server's while 1 loop when I click on Send. I have tried:

$trm = "\0" , Asc("NUL"), Chr(0), Chr(13)&Chr(10), Asc("CR"),Asc(" LF"), Asc("CR")&Asc("LF"), @CRLF

For the life of me I have no idea what $/="\0" actually is in Perl other than "empty byte" or "null byte"....not sure if there is a difference.

Anyways, this was just meant to be fun but I feel like I am so close and I would love to play around with Flash and a simple socket server on localhost. I'm on vacation for another week so hoping to maybe get this working. I know this isn't what AI is for but I am sure it can do the job well enough to 'play around'.

Thanks for reading my *very* long post, and for any advice. :lmao:

Share this post


Link to post
Share on other sites



No takers? Oh well, was worth a shot. If I get it working I will post the code.

AutoIt is still great anyways. :lmao:

Share this post


Link to post
Share on other sites

dont know for sure but you might try just "" thats usually autoit for nothing .... :lmao:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

:lmao: Yes, is AI for 'nothing', but is not the same as 'empty byte'. ASCII Code 0 (zero) is 'null' or empty byte..not the same as 'empty string'. For some reason nothing I have tried is working. ;)

Hm. Also tried "\r\n" and "\n" and ASCII equivalents, but nada. Have I ran into some AI limitation or my own limitation? o:)

Thanks

EDIT: Has anything to do with the way the data is handled from the GUI input box?

Global $trm = " " ; or "" or Chr(0)...like I said I have tried them all I think.

$ret = DLLCall( "au3xtra.dll", "int", "TCPSend", "int", $ConnectedSocket, "str", GUICtrlRead($input) & $trm) ;<--

I have tried also:

$strStr=GUICtrlRead($input)

$strStr=$strStr&Chr(0)

$ret = DLLCall( "au3xtra.dll", "int", "TCPSend", "int", $ConnectedSocket, "str", $strSrt) ;<--

Edited by rhg

Share this post


Link to post
Share on other sites

Ah ok...I will update to the latest beta and replace the DLLCall's with the new functions...Thanks for the tip Larry.

Will post back soon enough (I hope :lmao: )

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Larry, as expected your instruction is flawless sir. ;)

Steps:

1) Download and installed the latest AI+SciTe Beta, AI+SciTeUpdate and v108 Beta

2) Copied and pasted the code from the AutoIt help section on TCPSend to SciTe. ( Seemed simpler than editing the individual lines.)

3) I am still working my way around in SciTe as it seems I had to use the Beta Compiler directly from the Programs menu in order to compile. (Start->Programs->AutoIt v3->beta->Compile Beta) Trivial, but worth mentioning I guess.

A non-trivial problem though...I am recieving an error when SOCKET2IP() UDF is triggered upon client connection for the line. The error returned in SciTe:

C:\AU3\fla_sockets.au3(142,29) : ERROR: DLLStructDelete(): undefined function.

DLLStructDelete($sockaddr)

For some reason (maybe b/c is Beta?) I had to comment that entire function out including all references to it in the UDF for it to 'act' properly and not error out. Not that I need it to work as I am on just testing on localhost, but I am curious if I haven't screwed something up with installing Beta or just being a n00b.

Again thanks for the tip! Made my day to see it work finally. :lmao: You guys are awesome.

EDIT: I *did* try DllStructDelete vs DLLStructDelete but that did not seem to help either. (DllStructDelete is what is in the Help File.)

Edited by rhg

Share this post


Link to post
Share on other sites

A non-trivial problem though...I am recieving an error when SOCKET2IP() UDF is triggered upon client connection for the line. The error returned in SciTe:

C:\AU3\fla_sockets.au3(142,29) : ERROR: DLLStructDelete(): undefined function.

DLLStructDelete($sockaddr)

You can replace:

DLLStructDelete($sockaddr)

With this:

$sockaddr = 0

Share this post


Link to post
Share on other sites

@Larry

Roger..I am on it. ;)

@big_daddy

Thanks for the tip. :lmao:

Share this post


Link to post
Share on other sites

is there now a answer how to make a empty byte ?

Share this post


Link to post
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
Sign in to follow this  
Followers 0