Still having issues with loading site
This commit is contained in:
parent
42bf316ccb
commit
abab69344a
@ -13,27 +13,30 @@ void TestSockets(int sender_s, int receiver_s) {
|
||||
std::cout << "Attempting to send data to receiver" << std::endl;
|
||||
do {
|
||||
buf_len = recv(sender_s, in_buf, BUF_SIZE, 0);
|
||||
std::cout << "LOG (info) - pipe packet recv size: " << buf_len << std::endl;
|
||||
if (buf_len == -1) {
|
||||
std::cout << "ERROR (info) - recv" << std::endl;
|
||||
return;
|
||||
}
|
||||
if (buf_len == 0) { continue; }
|
||||
send(receiver_s, in_buf, buf_len, 0);
|
||||
std::cout << "LOG (info) - pipe packet size: " << buf_len << std::endl;
|
||||
} while (buf_len > 0);
|
||||
if (buf_len == 0) { break; }
|
||||
buf_len = send(receiver_s, in_buf, buf_len, 0);
|
||||
std::cout << "LOG (info) - pipe packet send size: " << buf_len << std::endl;
|
||||
} while (buf_len == BUF_SIZE);
|
||||
std::cout << "Sent data to receiver" << std::endl;
|
||||
|
||||
// Pass response along from server to browser
|
||||
std::cout << "Attempting to send to browser" << std::endl;
|
||||
do {
|
||||
buf_len = recv(receiver_s, out_buf, BUF_SIZE, 0);
|
||||
buf_len = recv(sender_s, out_buf, BUF_SIZE, 0);
|
||||
std::cout << "LOG (info) - proxy packet recv size: " << buf_len << std::endl;
|
||||
if (buf_len == -1) {
|
||||
std::cout << "ERROR (info) - recv" << std::endl;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
if (buf_len == 0) { continue; }
|
||||
send(sender_s, out_buf, buf_len, 0);
|
||||
std::cout << "LOG (info) - proxy packet size: " << buf_len << std::endl;
|
||||
} while (buf_len > 0);
|
||||
if (buf_len == 0) { break; }
|
||||
buf_len = send(receiver_s, out_buf, buf_len, 0);
|
||||
std::cout << "LOG (info) - proxy packet send size: " << buf_len << std::endl;
|
||||
} while (buf_len == BUF_SIZE);
|
||||
std::cout << "Sent to browser" << std::endl;
|
||||
close(sender_s);
|
||||
close(receiver_s);
|
||||
@ -55,7 +58,7 @@ void PipeSockets(int sender_s, int receiver_s) {
|
||||
if (buf_len == 0) { break; }
|
||||
buf_len = send(receiver_s, in_buf, buf_len, 0);
|
||||
std::cout << "LOG (info) - pipe packet send size: " << buf_len << std::endl;
|
||||
} while (buf_len < BUF_SIZE);
|
||||
} while (buf_len == BUF_SIZE);
|
||||
std::cout << "Sent data to receiver" << std::endl;
|
||||
|
||||
}
|
||||
@ -70,13 +73,16 @@ void ProxySockets(int sender_s, int receiver_s) {
|
||||
buf_len = recv(sender_s, out_buf, BUF_SIZE, 0);
|
||||
std::cout << "LOG (info) - proxy packet recv size: " << buf_len << std::endl;
|
||||
if (buf_len == -1) {
|
||||
std::cout << "ERROR (info) - recv" << std::endl;
|
||||
std::cout << "ERROR (info) - recv -1" << std::endl;
|
||||
return;
|
||||
}
|
||||
if (buf_len == 0) {
|
||||
std::cout << "ERROR (info) - recv 0" << std::endl;
|
||||
return;
|
||||
}
|
||||
if (buf_len == 0) { break; }
|
||||
buf_len = send(receiver_s, out_buf, buf_len, 0);
|
||||
std::cout << "LOG (info) - proxy packet send size: " << buf_len << std::endl;
|
||||
} while (buf_len < BUF_SIZE);
|
||||
} while (buf_len == BUF_SIZE);
|
||||
std::cout << "Sent to browser" << std::endl;
|
||||
close(sender_s);
|
||||
close(receiver_s);
|
||||
|
@ -121,9 +121,8 @@ void ClientRequest(int client_s) {
|
||||
// Receive the GET request from the Web browser
|
||||
retcode = recv(client_s, in_buf, BUF_SIZE, 0);
|
||||
|
||||
if (retcode == -1) { std::cerr << "ERROR (info) - recv" << std::endl; }
|
||||
// Handle the GET if there is one (see note #3 in the header)
|
||||
if (retcode != -1)
|
||||
{
|
||||
// Parse out the filename from the GET request
|
||||
strtok(in_buf, " ");
|
||||
file_name = strtok(NULL, " ");
|
||||
@ -145,9 +144,7 @@ void ClientRequest(int client_s) {
|
||||
send(client_s, out_buf, strlen(out_buf), 0);
|
||||
strcpy(out_buf, MESS_404);
|
||||
send(client_s, out_buf, strlen(out_buf), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf("File %s is being sent \n", &file_name[1]);
|
||||
if (strstr(file_name, ".gif") != NULL)
|
||||
strcpy(out_buf, OK_IMAGE);
|
||||
@ -156,11 +153,10 @@ void ClientRequest(int client_s) {
|
||||
send(client_s, out_buf, strlen(out_buf), 0);
|
||||
do {
|
||||
buf_len = read(fh, out_buf, BUF_SIZE);
|
||||
send(client_s, out_buf, buf_len, 0);
|
||||
} while (buf_len > 0);
|
||||
buf_len = send(client_s, out_buf, buf_len, 0);
|
||||
} while (buf_len == BUF_SIZE);
|
||||
close(fh);
|
||||
}
|
||||
}
|
||||
// Close the client socket and end the thread
|
||||
close(client_s);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user