Assuming you want to access a local server, Apache is active and a connection is made through Socket, after connecting to the server, it is necessary to pass 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);
The Webservers take the information of the user q accesses the server through this header. So there is no need to use the curl
to apply to the server.
It is unclear what you have and exactly where you are at. Is the problem reading socket data? Interpreting http request? In sending a valid reply?
– Guilherme Bernal
I apologize, when I asked the question, there was no attempt that the server only accepts http connections on port 443 with Ssl, connection that Curl does automatically, for this reason that on Curl always returns and socket no. I am implementing the connection via SSL in the socket in question. Thank you
– Alessandro