user2707674
user2707674

Reputation: 333

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?

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

Upvotes: 0

Views: 132

Answers (1)

The_asMan
The_asMan

Reputation: 6402

Right after connection to the server the client socket will send a request for the crossdomain file, it will look like this

 <policy-file-request/>

You probably have seen this in the server logs

At this time the server should send the file back via the socket connection.

Once the client gets the file it will probably close the connection.

Now you need to restart the connection and send all your data without hinderance.

Upvotes: 1

Related Questions