This is signature of libwebsocket_client_connect()
.
struct libwebsocket * libwebsocket_client_connect (struct libwebsocket_context * context, const char * address, int port, int ssl_connection, const char * path, const char * host, const char * origin, const char * protocol, int ietf_version_or_minus_one)
And in these parameters, i am confused with what host
and origin
are.
in the description on the parameter, it is saying
host : Hostname on server
origin : Socket origin name
It seems domain name or IP address of server and client each.
And Only when i put the 127.0.0.1 or localhost, it works normally(since i tested within localhost both websocket server and client)
But if so, i think the function already has address field for server IP or domain name, why does it have likely duplicated field?
The host is the target of the request, while the origin is the domain where the websocket client was created. For example, if you have a page on example1.com, and that page opens a websocket to example2.com, then example1.com will be the origin, and example2.com the host.