Hi Robert,
Thank you very much for the tip. I didn't think the Flash socket would do
that, but apparently that's exactly what's happening. I implemented
something very similar to your suggestion and it's working.

This'll be a perfectly fine hold-over while I finish up some other portions
of the app. I don't intend to use packets full of XML forever, but it works
for now.

After buffering the data, it looks like Flash was splitting up the 4400-byte
socket into three pieces, and now it's pulling it altogether successfully.

Thanks very much for the advice!
-Michael

On Wed, May 7, 2008 at 11:58 AM, Robert Cadena <[EMAIL PROTECTED]>
wrote:

>   Hi Michael,
>
> the socket might be buffering your data, so a blunt for approach is to do
> is keep aggregating the data into a buffer and attempt to parse it, if it
> parses correctly then you can close the socket, if not then keep waiting
> until either the socket is closed remotely or you get all the data.  Here's
> some pseudocode:
>
>
> var buffer:String = "";
>
> function onSocketData(event:Event)
> {
>    buffer += event.data;
>
>    try
>    {
>       xml = new XML(buffer);
>
>       // if no parsing error, then the packet is complete:
>       socket.close();
>       notifyPacketComplete();
>    }
>    catch (e:Error)
>    {
>       trace("oops, maybe not done yet, i'll wait");
>       // do nothing and onSocketData will be called again
>    }
> }
>
> good luck
>
> /r
>
> http://www.searchcoders.com/
>
> On Tue, May 6, 2008 at 1:28 PM, Michael Baird <[EMAIL PROTECTED]> wrote:
>
> > Working with the AS3 Socket class, I'm trying to connect to a .NET
> > socket server. I can establish the connection and send and receive
> > data successfully, but if the data from the server-side is greater
> > than 1260 bytes, the packet gets severed.
> >
> > However, this isn't always the case... My packet is variable in size,
> > and the largest one so far has been 4466 bytes, the smallest under
> > 200. On the first try, I was able to receive all 4466 bytes. However,
> > on the subsequent tries, Flex is only loading in 1260...
> >
> > I know the server is sending all 4466 bytes because I am tracing out
> > the amount of bytes written to the socket after sending (the
> > asynchronous Socket.EndSend method in .NET returns the number of bytes
> > written after sending data across a socket).
> >
> > Here is my trace:
> > INFO: [StatusCommand.execute] Polling server with info object
> > INFO: [ServerDelegate.pollServer_socketConnected] Socket connected!
> > INFO: [ServerDelegate.pollServer_socketDataReceived] Socket data
> > received! [4466 bytes received]
> > INFO: [ServerDelegate.pollServer_socketClosed] Socket connection closed.
> >
> > INFO: [StatusCommand.execute] Polling server with info object
> > INFO: [ServerDelegate.pollServer_socketConnected] Socket connected!
> > INFO: [ServerDelegate.pollServer_socketDataReceived] Socket data
> > received! [1260 bytes received]
> > ERROR: [HomeProxy.pollServer_callback] Error retrieving server results:
> > TypeError: Error #1090: XML parser failure: element is malformed.
> > INFO: [ServerDelegate.pollServer_socketClosed] Socket connection closed.
> >
> > Right now it's an XML string inside the packet that I'm reading, which
> > is why I need to have the whole packet. =)
> >
> > Is there a limitation on the number of bytes that the AS3 socket can
> > receive? Is there any known bug that would cause this problem?
> >
> > Thanks in advance...
> >
> >
> > ------------------------------------
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> > Links
> >
> >
> >
> >
>  
>

Reply via email to