android - How to detech FIN (Close) in TCP connection -
i'm learning how use android/java socket class , need respond in particular way close (fin, really) sent remote computer.
the socket class not seem event-driven (http://developer.android.com/reference/java/net/socket.html) i.e., there don't seem onthis or onthat handlers, what's best way become aware of when remote computer sends fin?
currently android os responds fin ack, need things in application need way app alerted this.
thanks in advance!
you, application programmer, if ever need care fins , acks. they're built tcp/ip stack, , os take care of you. you're going low-level own good; if want mess stuff, won't able use socket -- you'd need raw sockets , such, way more work you're ready for. (i'm not sure if java or android let it.)
as detecting other end closing side of connection (which fin is), read socket. if other end has shut down sending side, read read 0 bytes (or return -1, depending on whether you're trying read bunch of bytes or one).
Comments
Post a Comment