AS3 socket class connection with serproxy and sending data

丶灬走出姿态 提交于 2019-12-08 20:05:31

Where is your socket.flush() command?? :)

It's also good practice to do.

socket.writeUTFBytes("This is a test for E" + String.fromCharCode(0) );

Ending with a null character helps in most cases.

But yeah remember to flush the socket after you write to it.

I don't see a problem with your code. Nothing that would make it break, unless the second frame is a keyframe, in which case the socket in the first frame would be destroyed, once you navigate away from the first frame. (In general timeline code is intended to make it easier for graphic designers to script animations. If you are going to maintain somewhat larger code base, I'd suggest you write code in separate *.as files.

Few things to try: Wireshark / tcpdump - these are the programs capable of monitoring all traffic on all ports of your PC. By using them you could at least see where the data sent is lost. I'd make, at least for the sake of experiment, a simple TCP listening socket and try connecting to it to see if the problem is there.

In general, there are few other things to try to connect to parallel port or USB - since AIR 3 there's an option for native extensions (ANE), it's very new yet and poorly documented, but I'd rather go with that one, especially if writing in language other than AS isn't an issue. Yet another way to communicate with another application outside AIR runtime is by using native process. I.e. you would launch an application responsible for connection to the port / device you need and then use the native process to read/write, just as you would with socket connection.

The combo i use is

socket.writeUTFBytes(myMessage);
socket.writeByte(0);
socket.flush();

I also recommend for debugging purposes

HW Group's Hercules

I hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!