Use inet:socket() as gen_tcp:socket() is not exported
Comply with gen_fsm callback interface
Use specific inet/ssl/gen_tcp types
Accept lists of binaries returned by wsock_message:encode
Make function return values comply with specs
Specify that some #data{} fields might be undefined
Update on_close_callback type definition

I consider this definition temporary,
but necessary to make both Dialyzer happy and the code free of crashes.