mIRC Homepage
Posted By: GodGell HTTP server - 14/04/03 06:17 PM
Hi.

I was maked a HTTP server in mirc script. In the first version, when a browser GET-ed a file, the server was sended the full file in a while. it readed 8192 byte into a binary variable and then sended it. it was sended the first 8k only and then fulled the status with error messages. i was rewrited it, so it sends the first 8k, then waits for the on sockwrite, and then sends the next 8k. i was proven it. it worked with little html files, but when i downloaded a picture from it, it sended a cute image, and a lot of "* /sockwrite: 'intra_1' queue would exceed 16384 bytes (line 280, szerver.mrc)" error messages. now, i was rewrited it again... now it waits 700 miliseconds (0.7 sec) before every 8k. now it sends full images, and faster, and does not freeze the server so it can send multipe images at the same time. but with bigger binary files (like a 10mb exefile), sometimes it sends error messages ("* /sockwrite: 'intra_1' queue would exceed 16384 bytes (line 280, szerver.mrc)"). if it would wait a full sec between every 8k, it would quite slow. help me wink if you wanna test it, i maked a link to it: www.g-intra.tk, but if im not online it will not work offcourse smile
Posted By: Collective Re: HTTP server - 14/04/03 06:24 PM
I made an HTTP server, mine works fine...code is full of [self censored] so I won't post it, but it works by having 2 aliases (A and B) constantly calling eachother. A sends data to the client and then calls B after a 1ms delay. B then calls A which calls B after 1ms..etc. The 1ms timer gives it time to send the data. I have transfered a 100mb file with this method, so it doesn't seem to have a size limit.
Posted By: Nimue Re: HTTP server - 14/04/03 06:31 PM
You should check $sock(name).sq to see how much data is queued to send before trying to sockwrite more.
Socket Identifiers

$sock(name,N)
This returns information about a socket connection that you created using the socket commands.

Properties: name, ip, port, status, sent, rcvd, sq, rq, ls, lr, mark, type, saddr, sport, to, wserr, wsmsg, bindip, bindport

.name is the name you give to a connection to identify it

.sent and .rcvd return the number of bytes sent and rcvd over that connection so far
.sq and .rq return the number of bytes queued in the send and receive buffers respectively
Posted By: GodGell Re: HTTP server - 14/04/03 10:37 PM
how fast is your net connection? i think on my 48k net, 1ms is not enough. and i think it would fully freezee mirc while sending, so if someone downloads another user cant. ehhehe.. but i test your method.
Posted By: codemastr Re: HTTP server - 15/04/03 03:18 AM
May I ask why you feel the need to run a HTTP server that has a speed of 48k/s?
Posted By: Pasmal Re: HTTP server - 15/04/03 07:46 AM
Use the on SOCKWRITE event to detect when you are able to send more data.

Edit: Hm, you say you do. Interesting. Check the send queue like the other person suggested, plus perhaps reduce the amount of data sent per write to 4096.
Posted By: Online Re: HTTP server - 15/04/03 09:08 AM
The "queue exceeded" error occurs with files that launch IE's download dialog. It probably happens because the dialog actually pauses the download while awaiting input.

To avoid this error, the send queue has to be checked before any packet is sent, to verify whether or not there's enough space left.
Posted By: Collective Re: HTTP server - 15/04/03 10:22 AM
BAH! Tested on a LAN my script uploaded at 839kb/s, adding 2 more users downloading at the same time (also on the LAN) had no effect. Perhaps a fraction of what Apache does...but still plenty for a little clan site run by people who are computer-stupid. I'm sure he could get the same results..or perhaps better if he knows something I don't.

Of course it might not work the same way on the Internet...but I couldn't test that as my ISP only gives me an upload of 10KB/s.

P.S. I know mIRC is a crappy language for writing such things, but it is still fun smile
Posted By: Watchdog Re: HTTP server - 15/04/03 12:03 PM
P.S. I know mIRC is a crappy language for writing such things, but it is still fun

Not always, it's a case of whateve works. :tongue:
Posted By: GodGell Re: HTTP server - 15/04/03 02:52 PM
ehh.. i rewrited it again smile now it works fine for LAN. it is sended with 2.5mb/s and no error messages.. but i asked a friend to download a file from it. a little (200kb) bitmap is always stopped the server. and now it sending ok, but very slow. my internet connection is slows down, but the downloader is getting the file only with 1.45k/s. (the user who downloads have an adsl). ehhehe. i think this webserver will be good for little files and verygood for big LAN transfers..eh i wanna write an ftp server but i'm still not intelligent for the FTP's datasock transfers. (:)

© mIRC Discussion Forums