Reputation: 9166
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?
Upvotes: 0
Views: 1909
Reputation: 35965
Host http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
The Host request-header field specifies the Internet host and port number of the resource being requested, as obtained from the original URI given by the user or referring resource (generally an HTTP URL).
Origin https://www.rfc-editor.org/rfc/rfc6454#section-7.2
When included in an HTTP request, the Origin header field indicates
the origin(s) that "caused" the user agent to issue the request, as
defined by the API that triggered the user agent to issue the
request.
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.
Upvotes: 2