-
Protocol Requests
I'm writing a program for a small server (at least it started out small, but it's been going a lot better than I expected), and I'm adding support for more than just HTTP. I'm also gonna add CGI, etc... but before I do that, I need to build some precautions into the HTTP code so that it won't be too much of an upgrade to add things like FTP. HTTP request lines are of the form
(METHOD) (Encoded URL) (HTTP/1.?), so you can't quite easily write code to split this up using " " as a delimiter and make a 3-element array, and then get the protocol name from array[2]. Now do other protocol's requests follow the same pattern? I would've looked this up on w3.org but I could find much about FTP at all. (I'm also assuming that it is even possible to have a server function in both FTP and HTTP capacities, so if it isn't, please let me know before I make an even bigger fool of myself).
-
Doesn't ftpd (or your ftp server whatever your OS may be) work for you?
Why do you want to reinvent the wheel?
-
Well, if no one ever reinvented the wheel, we'd all be riding on wooden spokes with iron tires... that'd really stink on an SUV :p
Sorry to intrude, just couldn't pass up the wheel thing.
-
It is indeed possible to have a server that accepts both FTP and HTTP protocols.
The problem is that it would be hell to maintain. You shouldn't have to differenciate(sp?) between FTP and HTTP requests because each one uses a different port. Therefore you should spawn a child or call the code that deals with FTP.
-
Ah! The port - thanks. Didn't think of that.
And jim - I'm sorry, I couldn't resist, but I just did a very sarcastic post on the C++ board (check it out - http://cboard.cprogramming.com/showthread.php?t=54330) and I'm on a roll, but for anybody who's seen RocketMan:
Wheel reinvention is my Chinese Neighbor's middle name!