I am working on an application that processes TCP / UDP streams in native Android code, but closing streams really does not work. I mean, when I first initiated a TCP connection, I get something like id 43, which I redirect to the channel. When I close the connection (along with the file descriptor), I start a new connection, but instead of getting the same channel identifier, this time I move on to something like pipe 53.
A few more open / close operations, and I get a 56 handset, which for some other reason cannot handle the input correctly and my program crashes. I am testing closing fd with
if (close(fd) < 0) {
/*log it */
}
and it never reports an error, but the file descriptor identifiers continue to increase until I restart the program and then return to the 40-value.
Any help is appreciated, thanks!
source
share