Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Http server using winsock
#1
A working http server made in freebasic, using winsock. It has a primitive php implementation (only GET vars are passed on), as well as a likely primitive qb implementation (using qb-interpreter to create html content, but passes GET vars via command$, so they all go uppercase).

Download link: http://qh2.qbtk.com/392-d ~700kb, since the php dll is included.

To test it, just run the htt-rix.exe file, and go to "localhost" in your browser. Be sure that you're not running any other webservers at the same time.

It has a not so fancy quirk though. If you view one of the pages containing a phpinfo() output, something very weird happens, and the server can't serve anymore. Just to make it more weird, this doesnt happen if you first play around abit with the qbasic created page (submit some text via the text box). I've been trying all day to figure out what makes this happen, without any luck. It seems as if the variables are totally screwed up, and it even stops printing in the middle of it all (ie, doing PRINT "(" + var$ + ")", only print the first "(" then nothing more).

Also all this doesnt happen with smaller php scripts.

I'd really appreciate if anyone could give me a hint on what's going wrong here.
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#2
Nice ;)

The runtime library is not thread-safe (it's on the TODO list), so you have to create mutexes when calling any rtlib procs from a thread (and also when accessing your globals). That's probably the cause of vars been screwed up after some time.. mutexes can be created intrinsic, see the mutex example.
Reply
#3
hm, on the not thread safe rtlib. would that mean that string manipulations too fall into the category not thread safe? then i guess i know why fbirc crashes at unpredictable times.

btw, a wow on the webserver zap
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#4
Thanks for the feedback Big Grin

I'll look into mutexes and try to rewrite the server to use that. Thanks Smile
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#5
The main things I would like is:

$_POST passed to PHP, and to QB in some form, along with file uploads.
Ability to block QB apps in selected DIR's
In the future FTP server and control panel.
atos-Software
http://www.datacentertalk.com - interested in how web hosting works? Here the place to go to find out.
[Image: 42-r]
Reply
#6
I'll add $_POST stuff as soon as I figure how to. ANd I know there must be a way, since other servers who use the php.exe directly pass this var on... Xitami for example. And if I get that to work, file uploads should work too.

For the blocking of qb apps in special dirs, when the configuration script thing gets more advanced, I plan to make it possible to control in which dirs php, qb, and whatever else extension is allowed to execute.

About the control panel, I don't think a such a thing should be part of the server itself, take Apache, for example, it doesnt has a control panel. A control panel would be a individual proggy, which changed the conf file, and controled start, stop, and restart of the server. If I figure how to do gui programs with fb, Ill start thinking about this Wink

And the ftp thing, that would also be a different project. Having a http and a ftp server in the same program is kinda messy, I think. I'd rather do it as a seperate program. With the troubles I'm having with threads now, I'd prefer not to add a bunch of other shared vars and what not on top Tongue
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#7
Zap, nice =P I am trying it now.
Reply
#8
Quote:I'll add $_POST stuff as soon as I figure how to. ANd I know there must be a way, since other servers who use the php.exe directly pass this var on... Xitami for example. And if I get that to work, file uploads should work too.

Right Zap, I have had a wade through the Xitami source Zap. Anyway I didn't find out how to do post but I did find out a few things through a later search on w3c

POST and PUT data is passed to CGI using something called CGI interface script input.

Try this search string on google:
cgi interface "script input" POST


A lot of confusing information but I suspect that will get you somewhere. Also I did this is on google.co.uk



One last thing (for now) how easy would it be to allow the server to run compiled QB apps, and to have a system where if these compiled QB apps print certain information in changes server settings so for example if a QB app printed this

#server code start#
somevariable=somevalue
#server code end#

that it would change that somevariable to equal somevalue.
I would like to use this specifically for updating config variables.
atos-Software
http://www.datacentertalk.com - interested in how web hosting works? Here the place to go to find out.
[Image: 42-r]
Reply
#9
jatos you could to the classic file interface system were you use a file as the medium to transfer information from the QB program to the WEB server program. an example of this would be DS4QB for extra speed you could use a ram drive which would speed things up a lot.


but the biggest question i have is why the hell would you want to do this outside of nostalgia for using QB.

if you just want to recyle old code then take your old code place it in a DLL format compile as a DLL in FB and then you could have the web server use the dll as a plug in which would be all around faster and better.
Reply
#10
Quote:jatos you could to the classic file interface system were you use a file as the medium to transfer information from the QB program to the WEB server program. an example of this would be DS4QB for extra speed you could use a ram drive which would speed things up a lot.


but the biggest question i have is why the hell would you want to do this outside of nostalgia for using QB.

if you just want to recyle old code then take your old code place it in a DLL format compile as a DLL in FB and then you could have the web server use the dll as a plug in which would be all around faster and better.


Zap has put something into his web server that captures the printed output of a qbasic bas and puts to the person requesting a page. I would like to be able to make changes to the server using that printed output.

Also, have you used the web server? It seems to me that you don't actually know how it works, correct if I am wrong, but te fact your talking about putting stuff into files like this suggest that you do not understand how the server works.
atos-Software
http://www.datacentertalk.com - interested in how web hosting works? Here the place to go to find out.
[Image: 42-r]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)