Socket creation rarely fails except for invalid parameters or extremely low-resources conditions (but in those cases generally nothing works so attempting recovery is an impossible mission).
What can fail at runtime is for example a listen
call because another process already is listening on the same port.
In windows socket creation most commonly fails because the the winsock initialization call has not been performed. This is IMO an horrible design bug in the API (so bad that makes me think it's an intentional attempt at prevent portability for no real reason).