c - crash network and consequent state of socket -


i know how state of socket become when network on work crashes. problem when simulate collapse of network select() function, controls socket, returns me socket theoretically should not set. it's possible operating system set crashed socket both in writing , in reading?

the first thing keep in mind computer typically not know when "network crashes" per se. computer know whether or not receiving packets network, or not. (some computers might know if electrical signal on local ethernet port has gone away, since possible more distant parts of network go down without affecting signal on local ethernet cable, information useful).

in practice, if network between computer , (the computer talking to) stops working, you'll see following effects:

(1) udp packets send dropped without trace, , without error indication. , of course won't receive udp packets remote peer either.

(2) data traffic on tcp connection between computer , remote peer grind halt. after timeout period (usually several minutes) has elapsed without os receiving responses remote peer, operating system "give up" , mark tcp connection closed; @ point see behavior identical if remote peer had deliberately closed connection: is, select() return ready-for-read (and possibly ready-for-write also, forget), , when try recv() or read() on socket, eof (i.e. recv() on blocking socket return 0; recv() on non-blocking socket return -1). (if network recovers before timeout completes, tcp traffic on socket resume, although start resuming , gradually speed again on time)


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -