What does End Of File mean on a socket?

Using Action Script 3 in Flex Builder 3.

While handling the SOCKET_DATA event, I sometimes seemingly accidentally get the error "Error # 2030: end of file". when calling socket.readInt (). I am confused as to what this error means as I am not reading the file? I'm a little unfair with nests. Thank.

+2


source to share


2 answers


when reading a socket that is closed, you get: Error #2002: Operation attempted on invalid socket.

end-of-file errors usually happen on any streams if you are reading more bytes than are available ... this goes for files, sockets, etc ... in case of a flash, this happens when reading from a Socket

or ByteArray

and possibly even others cases ...

TCP / IP is packet-based, but emulates a stream ... this way you can only read data from a stream that was already sent to you with TCP packets ... check Socket::bytesAvailable

to see how many bytes are currently ... always have in mind that the data you write to the socket in a single operation may come in multiple packets, each one probably causing the flash player to fire events socketData

...



Greetz

back2dos

+3


source


An end-of-file error usually means that the other side of the socket closed its connection, IIRC.

The reason this is the end of the file is because at a very low level in the program, a file on disk and a socket are both represented by a number - a file descriptor - that the OS is translated into an object representing a file, socket or pipe or whatever.

You can usually avoid this error by checking what you just read in EOF. If you read EOF and you try to read from socket / file again, you will get EOF error.




Update: According to the ActionScript 9.0 documentation , you do get a closed event if the other end closes the socket.
+7


source







All Articles