Thursday, 22 August 2013

actionscript tcp packets not delivered before closing socket

actionscript tcp packets not delivered before closing socket

I'm trying to code a simple actionscript tcp client, which is to send data
to a c++ tcp server. I'm new to actionscript and I'm using sample code
from adobe (see link below) for the client. I am able to make a connection
and send data, but the data is only available at the server when the
object is unloaded at the client side (hence closing the socket I guess).
I tried using a c++ client, and the data is immediately available at the
server, so I must be missing something on the client side. Maybe I need to
append some kind of termination/marker sequence? Thank you in advance for
any help!
actionscript code sending data over tcp:
private function tcpConnect():void
{
var customSocket:CustomSocket = new CustomSocket("127.0.0.1", 5331);
customSocket.timeout = 100;
socketWrite(customSocket, 53);
socketWrite(customSocket, 54);
socketWrite(customSocket, 55);
socketWrite(customSocket, 56);
}
private function socketWrite(sock:CustomSocket, b:int):void
{
sock.writeByte(b);
sock.writeByte(0);
sock.flush();
}
C++ tcp server:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms737593(v=vs.85).aspx
Actionscript tcp client:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html#includeExamplesSummary

No comments:

Post a Comment