Handle closed socket and NPE properly

Don't get interfaceIndex if the socket is closed. Properly catch NPE
instead of letting is propagating.

Test: TH
Change-Id: If962541e67dd6323426e46bc7a1f118786f83b9b
1 file changed