`
AquariusM
  • 浏览: 143485 次
  • 性别: Icon_minigender_1
  • 来自: 南阳
社区版块
存档分类
最新评论

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交互的教程,才发现是应该写事件的,但是我没有些;至于为什么写事件,以及事件写了以后有什么效果,仍然学习中。。。待续。。。
分享到:
评论
1 楼 caoshiyu2008 2013-08-27  
请问这个问题如何解决的?

相关推荐

Global site tag (gtag.js) - Google Analytics