Serial to Ethernet protocol transfer and display on default browser

Hello,

I'm trying to send HTTP request to an embedded server on a computer and get back the HTTP reply to simulate a small LAN using two Ethernet shields and two arduino UNOs. A computer terminal is connected to the arduino using ethernet, the web server is connected to the other arduino, the two arduinos are connected together serially using the the ALTSoftSerial library that utilizes pins 8 & 9 instead of traditional UART. My code works fine if the server reply is displayed on the serial monitor but I want to display the HTTP reply on default web browser like firefox. I have tried to use a combination of my code and the code of webserver example but with no decent results. I need some guidance concerning the combined code and I shall post the 2 codes below. (Note the same code is uploaded on both arduinos)

Code 1
#include <SPI.h>
#include <Ethernet.h>
#include <AltSoftSerial.h>

AltSoftSerial altSerial;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 }; //assigned arduino LAN IP address
byte server[] = { 192, 168, 1, 3 }; // laptop running apache LAN IP address
EthernetClient client; //apache web server running on port 80

void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(4800);
altSerial.begin(4800);
Serial.println("starting simple arduino client test");
Serial.println();

delay(1000);

Serial.println("connecting...");

if (client.connect(server,80)) {
Serial.println("connected");
client.println("GET /mohaa.txt HTTP/1.0"); //php page invoking my web service
client.println();
} else {
Serial.println("connection failed");
}
}

void loop()
{

char c;
if (client.available()) {
c = client.read();
altSerial.print(c);
Serial.print(c);
}
if (altSerial.available()>0) {
c = altSerial.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================================");
Serial.println("");
client.stop();
for(;;);
}
}


Code 2
#include <SPI.h>
#include <Ethernet.h>
#include <AltSoftSerial.h>

AltSoftSerial altSerial;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 1, 102};
byte server[] = {192, 168, 1, 3 };
EthernetClient client;

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
//EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(4800);
altSerial.begin(4800);

// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
//server.begin();
Serial.println("connecting...");

if (client.connect(server,80)) {
Serial.println("connected");
client.println("GET /mohaa.txt HTTP/1.0"); //php page invoking my web service
client.println();
} else {
Serial.println("connection failed");
}
}

void loop() {
// listen for incoming clients
//EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
altSerial.print(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("");
client.println("");
// output the value of each analog input pin

}
if (c == '\n') {
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}

mohamedmohsen:
Hello,

I'm trying to send HTTP request to an embedded server on a computer and get back the HTTP reply to simulate a small LAN using two Ethernet shields and two arduino UNOs. A computer terminal is connected to the arduino using ethernet, the web server is connected to the other arduino, the two arduinos are connected together serially

I'm having a lot of trouble visualising this setup. To me, "embedded server on a computer" is a contradiction in terms, and I don't know what a "computer terminal" is in this context. Can you explain the setup again in terms of computers, Arduinos, USB cables, Ethernet cables and then explain what sequence of interaction you're trying to achieve between them?

first the embeded webserver is just a simple virtual webserver (website or txt file) on a computer (implemented through XAMPP apache if you know it). As shown in the diagram, the design shows the computer on the left represents the client that sends the HTTP request connected through Ethernet Cable to the first Arduino. The Arduino is then connected serially using pin 8 and 9 to the other Arduino. The 2nd Arduino is connected through Ethernet to the computer on the right which represents the server. The Server should send the HTTP reply following the same sequence backwards. However, it isn't working and the browser on the left end doesn't show the HTTP reply.