2011-01-22 12:51:57 +00:00
|
|
|
#include "private-libwebsockets.h"
|
|
|
|
|
2013-10-26 20:23:00 +08:00
|
|
|
struct libwebsocket *libwebsocket_client_connect_2(
|
2011-05-23 10:00:03 +01:00
|
|
|
struct libwebsocket_context *context,
|
|
|
|
struct libwebsocket *wsi
|
|
|
|
) {
|
|
|
|
struct pollfd pfd;
|
|
|
|
struct hostent *server_hostent;
|
|
|
|
struct sockaddr_in server_addr;
|
2014-02-18 10:06:57 +01:00
|
|
|
struct sockaddr_in client_addr;
|
2011-05-23 10:00:03 +01:00
|
|
|
int n;
|
|
|
|
int plen = 0;
|
2013-02-11 13:04:45 +08:00
|
|
|
const char *ads;
|
2011-05-23 10:00:03 +01:00
|
|
|
|
2013-10-26 20:23:00 +08:00
|
|
|
lwsl_client("libwebsocket_client_connect_2\n");
|
2011-05-23 10:00:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* proxy?
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (context->http_proxy_port) {
|
2013-02-10 15:34:59 +08:00
|
|
|
plen = sprintf((char *)context->service_buffer,
|
2013-02-10 15:19:39 +08:00
|
|
|
"CONNECT %s:%u HTTP/1.0\x0d\x0a"
|
2011-05-23 10:00:03 +01:00
|
|
|
"User-agent: libwebsockets\x0d\x0a"
|
|
|
|
/*Proxy-authorization: basic aGVsbG86d29ybGQ= */
|
2013-02-11 13:04:45 +08:00
|
|
|
"\x0d\x0a",
|
|
|
|
lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS),
|
2013-02-18 10:38:45 +08:00
|
|
|
wsi->u.hdr.ah->c_port);
|
2013-10-25 22:07:57 +08:00
|
|
|
ads = context->http_proxy_address;
|
|
|
|
server_addr.sin_port = htons(context->http_proxy_port);
|
|
|
|
} else {
|
|
|
|
ads = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS);
|
|
|
|
server_addr.sin_port = htons(wsi->u.hdr.ah->c_port);
|
2011-05-23 10:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare the actual connection (to the proxy, if any)
|
|
|
|
*/
|
2013-10-26 20:23:00 +08:00
|
|
|
lwsl_client("libwebsocket_client_connect_2: address %s\n", ads);
|
2013-02-11 13:04:45 +08:00
|
|
|
|
|
|
|
server_hostent = gethostbyname(ads);
|
2011-05-23 10:00:03 +01:00
|
|
|
if (server_hostent == NULL) {
|
2013-02-11 13:04:45 +08:00
|
|
|
lwsl_err("Unable to get host name from %s\n", ads);
|
2011-05-23 10:00:03 +01:00
|
|
|
goto oom4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wsi->sock < 0) {
|
2013-09-20 20:26:12 +08:00
|
|
|
|
|
|
|
wsi->sock = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
|
|
|
|
if (wsi->sock < 0) {
|
|
|
|
lwsl_warn("Unable to open socket\n");
|
|
|
|
goto oom4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lws_set_socket_options(context, wsi->sock)) {
|
|
|
|
lwsl_err("Failed to set wsi socket options\n");
|
|
|
|
compatible_close(wsi->sock);
|
|
|
|
goto oom4;
|
|
|
|
}
|
|
|
|
|
|
|
|
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_CONNECT;
|
|
|
|
|
|
|
|
insert_wsi_socket_into_fds(context, wsi);
|
|
|
|
|
|
|
|
libwebsocket_set_timeout(wsi,
|
|
|
|
PENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE,
|
|
|
|
AWAITING_TIMEOUT);
|
2014-02-18 10:06:57 +01:00
|
|
|
|
|
|
|
bzero((char *) &client_addr, sizeof(client_addr));
|
|
|
|
client_addr.sin_family = AF_INET;
|
|
|
|
|
|
|
|
if (context->iface != NULL) {
|
|
|
|
if (interface_to_sa(context->iface, &client_addr,
|
|
|
|
sizeof(client_addr)) < 0) {
|
|
|
|
lwsl_err("Unable to find interface %s\n", context->iface);
|
|
|
|
compatible_close(wsi->sock);
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bind(wsi->sock, (struct sockaddr *) &client_addr,
|
|
|
|
sizeof(client_addr)) < 0) {
|
|
|
|
lwsl_err("Error binding to interface %s", context->iface);
|
|
|
|
compatible_close(wsi->sock);
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
}
|
2011-05-23 10:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
server_addr.sin_family = AF_INET;
|
|
|
|
server_addr.sin_addr = *((struct in_addr *)server_hostent->h_addr);
|
2013-10-25 22:07:57 +08:00
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
bzero(&server_addr.sin_zero, 8);
|
|
|
|
|
|
|
|
if (connect(wsi->sock, (struct sockaddr *)&server_addr,
|
2014-02-28 12:37:52 +01:00
|
|
|
sizeof(struct sockaddr)) == -1 || LWS_ERRNO == LWS_EISCONN) {
|
2011-05-23 10:00:03 +01:00
|
|
|
|
2014-02-28 12:37:52 +01:00
|
|
|
if (LWS_ERRNO == LWS_EALREADY || LWS_ERRNO == LWS_EINPROGRESS) {
|
2013-09-20 20:26:12 +08:00
|
|
|
lwsl_client("nonblocking connect retry\n");
|
2011-05-23 10:00:03 +01:00
|
|
|
|
2013-09-20 20:26:12 +08:00
|
|
|
/*
|
|
|
|
* must do specifically a POLLOUT poll to hear
|
|
|
|
* about the connect completion
|
|
|
|
*/
|
2013-12-21 11:18:34 +08:00
|
|
|
lws_change_pollfd(wsi, 0, POLLOUT);
|
2013-09-20 20:26:12 +08:00
|
|
|
|
|
|
|
return wsi;
|
|
|
|
}
|
|
|
|
|
2014-02-28 12:37:52 +01:00
|
|
|
if (LWS_ERRNO != LWS_EISCONN) {
|
2013-10-25 15:49:11 +02:00
|
|
|
|
2014-02-28 12:37:52 +01:00
|
|
|
lwsl_debug("Connect failed errno=%d\n", LWS_ERRNO);
|
2013-10-25 15:49:11 +02:00
|
|
|
goto failed;
|
|
|
|
}
|
2013-02-09 12:25:31 +08:00
|
|
|
}
|
|
|
|
|
2013-09-20 20:26:12 +08:00
|
|
|
lwsl_client("connected\n");
|
2011-05-23 10:00:03 +01:00
|
|
|
|
|
|
|
/* we are connected to server, or proxy */
|
|
|
|
|
|
|
|
if (context->http_proxy_port) {
|
|
|
|
|
2013-10-25 22:07:57 +08:00
|
|
|
/* OK from now on we talk via the proxy, so connect to that */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (will overwrite existing pointer,
|
|
|
|
* leaving old string/frag there but unreferenced)
|
|
|
|
*/
|
|
|
|
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS,
|
|
|
|
context->http_proxy_address))
|
|
|
|
goto failed;
|
|
|
|
wsi->u.hdr.ah->c_port = context->http_proxy_port;
|
|
|
|
|
2013-06-29 10:22:09 +08:00
|
|
|
n = send(wsi->sock, context->service_buffer, plen, MSG_NOSIGNAL);
|
2011-05-23 10:00:03 +01:00
|
|
|
if (n < 0) {
|
2013-01-10 19:50:35 +08:00
|
|
|
lwsl_debug("ERROR writing to proxy socket\n");
|
2013-09-20 20:26:12 +08:00
|
|
|
goto failed;
|
2011-05-23 10:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
libwebsocket_set_timeout(wsi,
|
2013-02-11 17:13:32 +08:00
|
|
|
PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE,
|
|
|
|
AWAITING_TIMEOUT);
|
2011-05-23 10:00:03 +01:00
|
|
|
|
|
|
|
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY;
|
|
|
|
|
|
|
|
return wsi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* provoke service to issue the handshake directly
|
|
|
|
* we need to do it this way because in the proxy case, this is the
|
|
|
|
* next state and executed only if and when we get a good proxy
|
2013-01-13 11:05:30 +08:00
|
|
|
* response inside the state machine... but notice in SSL case this
|
|
|
|
* may not have sent anything yet with 0 return, and won't until some
|
|
|
|
* many retries from main loop. To stop that becoming endless,
|
|
|
|
* cover with a timeout.
|
2011-05-23 10:00:03 +01:00
|
|
|
*/
|
|
|
|
|
2013-01-13 11:05:30 +08:00
|
|
|
libwebsocket_set_timeout(wsi,
|
|
|
|
PENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE, AWAITING_TIMEOUT);
|
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE;
|
|
|
|
pfd.fd = wsi->sock;
|
|
|
|
pfd.revents = POLLIN;
|
2013-01-09 16:17:04 +08:00
|
|
|
|
|
|
|
n = libwebsocket_service_fd(context, &pfd);
|
|
|
|
|
|
|
|
if (n < 0)
|
2013-09-20 20:26:12 +08:00
|
|
|
goto failed;
|
2011-05-23 10:00:03 +01:00
|
|
|
|
2013-01-09 16:17:04 +08:00
|
|
|
if (n) /* returns 1 on failure after closing wsi */
|
|
|
|
return NULL;
|
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
return wsi;
|
|
|
|
|
|
|
|
oom4:
|
2013-02-11 13:04:45 +08:00
|
|
|
free(wsi->u.hdr.ah);
|
2011-05-23 10:00:03 +01:00
|
|
|
free(wsi);
|
2013-09-20 20:26:12 +08:00
|
|
|
return NULL;
|
2011-05-23 10:00:03 +01:00
|
|
|
|
2013-09-20 20:26:12 +08:00
|
|
|
failed:
|
|
|
|
libwebsocket_close_and_free_session(context, wsi,
|
|
|
|
LWS_CLOSE_STATUS_NOSTATUS);
|
2011-05-23 10:00:03 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-27 06:26:52 +00:00
|
|
|
/**
|
|
|
|
* libwebsocket_client_connect() - Connect to another websocket server
|
2011-03-02 22:03:47 +00:00
|
|
|
* @context: Websocket context
|
2011-01-27 06:26:52 +00:00
|
|
|
* @address: Remote server address, eg, "myserver.com"
|
|
|
|
* @port: Port to connect to on the remote server, eg, 80
|
|
|
|
* @ssl_connection: 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
|
|
|
|
* signed certs
|
|
|
|
* @path: Websocket path on server
|
|
|
|
* @host: Hostname on server
|
|
|
|
* @origin: Socket origin name
|
|
|
|
* @protocol: Comma-separated list of protocols being asked for from
|
|
|
|
* the server, or just one. The server will pick the one it
|
|
|
|
* likes best.
|
2011-02-09 08:49:14 +00:00
|
|
|
* @ietf_version_or_minus_one: -1 to ask to connect using the default, latest
|
2012-04-09 15:09:01 +08:00
|
|
|
* protocol supported, or the specific protocol ordinal
|
2011-01-27 06:26:52 +00:00
|
|
|
*
|
|
|
|
* This function creates a connection to a remote server
|
|
|
|
*/
|
|
|
|
|
2013-03-30 09:52:21 +08:00
|
|
|
LWS_VISIBLE struct libwebsocket *
|
2011-03-02 22:03:47 +00:00
|
|
|
libwebsocket_client_connect(struct libwebsocket_context *context,
|
2011-01-22 12:51:57 +00:00
|
|
|
const char *address,
|
|
|
|
int port,
|
2011-01-27 06:26:52 +00:00
|
|
|
int ssl_connection,
|
2011-01-22 12:51:57 +00:00
|
|
|
const char *path,
|
|
|
|
const char *host,
|
|
|
|
const char *origin,
|
2011-02-09 08:49:14 +00:00
|
|
|
const char *protocol,
|
|
|
|
int ietf_version_or_minus_one)
|
2011-01-22 12:51:57 +00:00
|
|
|
{
|
|
|
|
struct libwebsocket *wsi;
|
2013-01-20 17:08:31 +08:00
|
|
|
#ifndef LWS_NO_EXTENSIONS
|
2013-02-18 10:43:18 +08:00
|
|
|
int n;
|
2011-05-23 10:00:03 +01:00
|
|
|
int m;
|
|
|
|
struct libwebsocket_extension *ext;
|
|
|
|
int handled;
|
2013-01-20 17:08:31 +08:00
|
|
|
#endif
|
|
|
|
|
2011-02-14 20:25:43 +00:00
|
|
|
#ifndef LWS_OPENSSL_SUPPORT
|
2011-01-27 06:26:52 +00:00
|
|
|
if (ssl_connection) {
|
2013-01-10 19:50:35 +08:00
|
|
|
lwsl_err("libwebsockets not configured for ssl\n");
|
2011-01-27 06:26:52 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2011-01-22 12:51:57 +00:00
|
|
|
|
2013-01-10 12:35:18 +08:00
|
|
|
wsi = (struct libwebsocket *) malloc(sizeof(struct libwebsocket));
|
2011-02-14 20:25:43 +00:00
|
|
|
if (wsi == NULL)
|
2013-02-11 21:43:41 +08:00
|
|
|
goto bail;
|
2011-01-22 12:51:57 +00:00
|
|
|
|
2013-02-11 17:13:32 +08:00
|
|
|
memset(wsi, 0, sizeof(*wsi));
|
2013-09-20 20:26:12 +08:00
|
|
|
wsi->sock = -1;
|
2011-02-14 17:52:39 +00:00
|
|
|
|
2011-02-09 08:49:14 +00:00
|
|
|
/* -1 means just use latest supported */
|
|
|
|
|
|
|
|
if (ietf_version_or_minus_one == -1)
|
2011-02-26 11:08:46 +00:00
|
|
|
ietf_version_or_minus_one = SPEC_LATEST_SUPPORTED;
|
2011-02-09 08:49:14 +00:00
|
|
|
|
|
|
|
wsi->ietf_spec_revision = ietf_version_or_minus_one;
|
2011-01-22 12:51:57 +00:00
|
|
|
wsi->user_space = NULL;
|
|
|
|
wsi->state = WSI_STATE_CLIENT_UNCONNECTED;
|
2011-02-01 08:52:55 +00:00
|
|
|
wsi->protocol = NULL;
|
2011-02-14 17:59:43 +00:00
|
|
|
wsi->pending_timeout = NO_PENDING_TIMEOUT;
|
2013-01-20 17:08:31 +08:00
|
|
|
#ifndef LWS_NO_EXTENSIONS
|
2011-03-05 16:12:15 +00:00
|
|
|
wsi->count_active_extensions = 0;
|
2013-01-20 17:08:31 +08:00
|
|
|
#endif
|
2011-02-14 20:25:43 +00:00
|
|
|
#ifdef LWS_OPENSSL_SUPPORT
|
|
|
|
wsi->use_ssl = ssl_connection;
|
|
|
|
#endif
|
|
|
|
|
2013-02-11 13:04:45 +08:00
|
|
|
if (lws_allocate_header_table(wsi))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we're not necessarily in a position to action these right away,
|
|
|
|
* stash them... we only need during connect phase so u.hdr is fine
|
|
|
|
*/
|
2013-02-18 10:38:45 +08:00
|
|
|
wsi->u.hdr.ah->c_port = port;
|
2013-02-11 13:04:45 +08:00
|
|
|
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS, address))
|
|
|
|
goto bail1;
|
2011-05-23 10:00:03 +01:00
|
|
|
|
2013-02-11 13:04:45 +08:00
|
|
|
/* these only need u.hdr lifetime as well */
|
2011-02-14 20:25:43 +00:00
|
|
|
|
2013-02-11 13:04:45 +08:00
|
|
|
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_URI, path))
|
2011-02-14 20:25:43 +00:00
|
|
|
goto bail1;
|
|
|
|
|
2013-02-11 13:04:45 +08:00
|
|
|
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_HOST, host))
|
|
|
|
goto bail1;
|
2012-04-20 12:16:52 +08:00
|
|
|
|
2013-02-11 13:04:45 +08:00
|
|
|
if (origin)
|
2013-02-11 17:13:32 +08:00
|
|
|
if (lws_hdr_simple_create(wsi,
|
|
|
|
_WSI_TOKEN_CLIENT_ORIGIN, origin))
|
2013-02-11 13:04:45 +08:00
|
|
|
goto bail1;
|
|
|
|
/*
|
|
|
|
* this is a list of protocols we tell the server we're okay with
|
|
|
|
* stash it for later when we compare server response with it
|
|
|
|
*/
|
|
|
|
if (protocol)
|
2013-02-11 17:13:32 +08:00
|
|
|
if (lws_hdr_simple_create(wsi,
|
|
|
|
_WSI_TOKEN_CLIENT_SENT_PROTOCOLS, protocol))
|
2013-02-11 13:04:45 +08:00
|
|
|
goto bail1;
|
|
|
|
|
|
|
|
wsi->protocol = &context->protocols[0];
|
2011-01-22 12:51:57 +00:00
|
|
|
|
2013-01-20 17:08:31 +08:00
|
|
|
#ifndef LWS_NO_EXTENSIONS
|
2011-01-22 12:51:57 +00:00
|
|
|
/*
|
2011-05-23 10:00:03 +01:00
|
|
|
* Check with each extension if it is able to route and proxy this
|
|
|
|
* connection for us. For example, an extension like x-google-mux
|
|
|
|
* can handle this and then we don't need an actual socket for this
|
|
|
|
* connection.
|
2011-01-27 22:01:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
handled = 0;
|
|
|
|
ext = context->extensions;
|
|
|
|
n = 0;
|
2011-01-27 22:01:43 +00:00
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
while (ext && ext->callback && !handled) {
|
|
|
|
m = ext->callback(context, ext, wsi,
|
|
|
|
LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
|
|
|
|
(void *)(long)n, (void *)address, port);
|
|
|
|
if (m)
|
|
|
|
handled = 1;
|
2011-01-27 22:01:43 +00:00
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
ext++;
|
|
|
|
n++;
|
2011-01-22 12:51:57 +00:00
|
|
|
}
|
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
if (handled) {
|
2013-01-10 19:50:35 +08:00
|
|
|
lwsl_client("libwebsocket_client_connect: ext handling conn\n");
|
2011-01-28 09:39:29 +00:00
|
|
|
|
2011-02-14 20:25:43 +00:00
|
|
|
libwebsocket_set_timeout(wsi,
|
2013-02-11 17:13:32 +08:00
|
|
|
PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE,
|
|
|
|
AWAITING_TIMEOUT);
|
2011-01-27 06:26:52 +00:00
|
|
|
|
2011-05-23 10:00:03 +01:00
|
|
|
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT;
|
2011-02-14 20:25:43 +00:00
|
|
|
return wsi;
|
2011-01-27 22:01:43 +00:00
|
|
|
}
|
2013-01-20 17:08:31 +08:00
|
|
|
#endif
|
2013-01-10 19:50:35 +08:00
|
|
|
lwsl_client("libwebsocket_client_connect: direct conn\n");
|
2011-01-22 12:51:57 +00:00
|
|
|
|
2013-10-26 20:23:00 +08:00
|
|
|
return libwebsocket_client_connect_2(context, wsi);
|
2011-01-22 12:51:57 +00:00
|
|
|
|
|
|
|
bail1:
|
2013-02-11 13:04:45 +08:00
|
|
|
free(wsi->u.hdr.ah);
|
|
|
|
bail:
|
2011-01-22 12:51:57 +00:00
|
|
|
free(wsi);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-04-20 12:19:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* libwebsocket_client_connect_extended() - Connect to another websocket server
|
|
|
|
* @context: Websocket context
|
|
|
|
* @address: Remote server address, eg, "myserver.com"
|
|
|
|
* @port: Port to connect to on the remote server, eg, 80
|
|
|
|
* @ssl_connection: 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
|
|
|
|
* signed certs
|
|
|
|
* @path: Websocket path on server
|
|
|
|
* @host: Hostname on server
|
|
|
|
* @origin: Socket origin name
|
|
|
|
* @protocol: Comma-separated list of protocols being asked for from
|
|
|
|
* the server, or just one. The server will pick the one it
|
|
|
|
* likes best.
|
|
|
|
* @ietf_version_or_minus_one: -1 to ask to connect using the default, latest
|
2013-02-11 17:13:32 +08:00
|
|
|
* protocol supported, or the specific protocol ordinal
|
2012-04-20 12:19:01 +08:00
|
|
|
* @userdata: Pre-allocated user data
|
|
|
|
*
|
|
|
|
* This function creates a connection to a remote server
|
|
|
|
*/
|
|
|
|
|
2013-03-30 09:52:21 +08:00
|
|
|
LWS_VISIBLE struct libwebsocket *
|
2012-04-20 12:19:01 +08:00
|
|
|
libwebsocket_client_connect_extended(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,
|
2013-02-11 17:13:32 +08:00
|
|
|
void *userdata)
|
2012-04-20 12:19:01 +08:00
|
|
|
{
|
|
|
|
struct libwebsocket *ws =
|
2013-02-11 17:13:32 +08:00
|
|
|
libwebsocket_client_connect(context, address, port,
|
|
|
|
ssl_connection, path, host, origin, protocol,
|
|
|
|
ietf_version_or_minus_one);
|
2012-04-20 12:19:01 +08:00
|
|
|
|
|
|
|
if (ws && !ws->user_space && userdata)
|
|
|
|
ws->user_space = userdata ;
|
|
|
|
|
|
|
|
return ws ;
|
2013-02-11 17:13:32 +08:00
|
|
|
}
|