ultifinitus
ultifinitus

Reputation: 1893

HTML Forwarding

So I've been playing around with some simple HTML forwarding with c++. Haven't accomplished much and I have some questions on the backbone.

First: Do I need to use any special libraries other than socket libraries to simply forward HTML data and connections?

Second: When a client connects to an HTML server, is the TCP connection kept open? Or is it closed once data is sent?

Third: When I forward data, from a client to the server, the packet includes the destination address. I should technically be able to read this address and connect to the server via port 80, keep it open, and send and receive on that newly opened port right? Is there anything I have to do? Any time constraints? If I directly forward every single packet directly between the client and server the website should show up correctly on the client, correct?

I would prefer to keep any external libs to a minimum. But if necessary I can expand the program to include any required libraries.

So far I've gotten data to and from both parties, however the website does not function.

[platform] :: windows.primary && posix_compliant.secondary

Upvotes: 0

Views: 115

Answers (2)

ultifinitus
ultifinitus

Reputation: 1893

After doing quite a bit of research, the greatest help I've had in my endeavors has been this website.

This one also helped quite a bit.

LibCURL is certainly the way to go. It's kind of dated, and everything is in C, but it's much easier than redoing everything..

quote from second site:
Like most network protocols, HTTP uses the client-server model: An HTTP client opens a connection and sends a request message to an HTTP server; the server then returns a response message, usually containing the resource that was requested. After delivering the response, the server closes the connection (making HTTP a stateless protocol, i.e. not maintaining any connection information between transactions).

Upvotes: 0

CashCow
CashCow

Reputation: 31435

First: No you do not need other special libraries but not using any that are available would to some extent be reinventing the wheel.

Second: No, HTTP is a connectionless protocol.

Third: An HTTP session begins with a request header, which in your case sounds like a POST. A POST may take more than one package, during which time the connection remains open. The server may well time you out.

You might look at libCURL even if you do not intend using it. (The source for that is in C, and is rather monolithic but it is commonly used).

Upvotes: 1

Related Questions