Does the socket exists before sending?

If the socket is not set up, the sent of the message SegFault the program.