Reputation: 22104
Could not find a direct answer to this anywhere. Can someone shed some lights. Thanks.
Upvotes: 1
Views: 5556
Reputation: 21268
There's no single C "command" (rather, function) to "open" a connection to a remote host.
First, you need a socket, this is provided by the socket()
function (see your documentation for relevant header files). Then, you need to call connect()
to establish the connection. However, that requires that all host names have been resolved, so you may have had to call gethostbyname()
or similar, to turn a hostname into an IP address.
Upvotes: 6
Reputation: 9897
On Winsock, that would be connect()
, but socket needs to be created first.
Upvotes: 1
Reputation: 1038920
There's no such command built into the language. Sockets need to be used but they are platform dependent.
Upvotes: 8
Reputation: 81404
#include <sys/types.h>
#include <sys/socket.h>
int socket(int domain, int type, int protocol);
Upvotes: 1