Assuming you want to access a local server, Apache is active and if you make a connection through Socket , after connecting to the server, a Header (Header).
main:
const int PORT = 8080;
int _sock;
int res;
char buffer[] = "GET / HTTP/1.1"
"Host: localhost:8080"
"User-Agent: WebBrowser (<GUI>; <OS>; rv:<version>)"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9"
"Accept-Language: pt-BR"
"Connection: keep-alive";
struct sockaddr_in serv;
struct hostent *server;
_sock = socket(AF_INET, SOCK_STREAM, TCP);
server = gethostbyname("127.0.0.1");
serv.sin_family = AF_INET;
serv.sin_port = htons(PORT);
bcopy((char *) server->h_addr,
(char *) &serv.sin_addr.s_addr,
server->h_length);
int len = sizeof(serv);
res = connect(_sock, (struct sockaddr *) &serv, len);
write(_sock,buffer, strlen(buffer))
while(1)
if(read(_sock, &c, 1) != 1)
break;
else
write(stdout, &c, 1);
close(_sock);
WebServers takes information from the user who accesses the server through this header. So you do not have to use curl
to make the request to the server.