MCPcopy Create free account
hub / github.com/apache/thrift / tcp_connect

Function tcp_connect

lib/lua/src/usocket.c:342–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342const char * tcp_connect(p_socket sock,
343 const char *host,
344 unsigned short port,
345 int timeout) {
346 // TODO support IPv6
347 int err;
348 struct hostent *h;
349 struct sockaddr_in remote;
350 memset(&remote, 0, sizeof(remote));
351 remote.sin_family = AF_INET;
352 remote.sin_port = htons(port);
353 if (strcmp(host, "*") && !inet_aton(host, &remote.sin_addr)) {
354 h = gethostbyname(host);
355 if (!h) {
356 return hstrerror(h_errno);
357 }
358 memcpy(&remote.sin_addr,
359 (struct in_addr *)h->h_addr_list[0],
360 sizeof(struct in_addr));
361 }
362 err = socket_connect(sock, (p_sa) &remote, sizeof(remote), timeout);
363 ERRORSTR_RETURN(err);
364}
365
366const char * tcp_create_and_connect(p_socket sock,
367 const char *host,

Callers 1

l_socket_connectFunction · 0.85

Calls 1

socket_connectFunction · 0.85

Tested by

no test coverage detected