This is one of the most misunderstood concept from software developers in respect to network admins, that typically arise around of the confusion between "network" and "link".
A soket is a relation between two remote IP addresses. There can be the entire Internet in between: there is no "cable from A to B". An B can be unreachable from A even if the cable in A is plugged.
Think to
A ----- R ----- R ---- R ---- B
\----R-----R---/
And since who sits on A cannot have the control of the entire state of all the links in between, there is no event local to A that can alone demonstrate A to B reachability.
Unplugging the cable simply makes the network card offline, but doesn't have any effect on IP (that is connectionless).
Of course, you can -with appropriate OS API- check the status of the card, but even if you find it "up" doesn't mean B is reachable.
If you operate on a TCP socket, you have to trust TCP in detecting errors.
Just try send something that requires an acknowledge (hence, more then 0 bytes), and TCP, not receiving it, will resend the data over and over up to the maximum retransmit timeout (usually 40 seconds). At that point TCP will fail and the socket will report the error.
Don't try to escape the waiting before, or make the timeout shorter: that timer are there for the good reason that -if a temporary unreachability happens- TCP must be able to sustain the socket allowing the underlying network routing to find an alternative path without breaking the session.