2010年7月29号--关于一个文件读取错误的问题

2010年7月29号 -- 关于Error:Error #2030:end of the file was encounted.

The socket is now connector... Error: Error #2030: 遇到文件尾。
at flash.net::Socket/readUTF() at send()

昨天在写as3.0与java服务端socket连接时的一个错误,上网上查看一些评论和注释,最后还是英文网站给我了真正的原因解析,此错误来源于
EOFError; An EOFError exception is thrown when you attempt to read past the end of the available data.For example,an EOFError is thrown when one of the read methods in the IDataInput interface is called and there is insufficient data to satisfy the read request.


下面是一个英文论坛网上的问题和解决办法:
Using Action Script 3 in Flex Builder 3:
When handing a SOCKET_DATA event,I occasionally,seemingly at random,get an "Error #2030:End of file was encoutered." When calling socket.readInt().I'm confused as to want this error means,since I'm not reading a file?I'm a little unfamilier with sockets.Thanks.

2 Answers:

when reading off a socket,that is closed,you will get:Error #2002:Operation attempted on invalid socket. end of fiel errors typically occur on any bytestreams,if you read more bytes than avaliable ... this is the case for files,sockets,etc....in the case of flash,it occurs when reading from a Socket or a ByteArray and maybe even in other cases...

TCP/IP is package based,but emulates a stream...thus you can only read the data off the stream,that was already sent to you with TCP packages...check Socket::byteAvaliable to find out,how many bytes are currently avaliable...always keep in mind,that the data you write to the socket in one operation may arrive in mutiple packages,each very probably causing flash player to trigger socketData events...

于是我就修改我的.as文件,查看socket.byteAvaliable 然后利用 socket.readUTFBytes(socket.byteAvaliable)进行查看,结果依然是这样,说明我根本没有接收到数据。 最后在javaEye上看到一个astionscript与socket交互的教程,才发现是应该写事件的,但是我没有些;至于为什么写事件,以及事件写了以后有什么效果,仍然学习中。。。待续。。。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值