mIRC Home    About    Download    Register    News    Help

Print Thread
#19228 14/04/03 06:17 PM
Joined: Dec 2002
Posts: 44
G
GodGell Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Dec 2002
Posts: 44
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


sorry for my bad english
watch out when you're in front of my scalar howitzer smile

Punks not dead!
#19229 14/04/03 06:24 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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.

#19230 14/04/03 06:31 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
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

#19231 14/04/03 10:37 PM
Joined: Dec 2002
Posts: 44
G
GodGell Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Dec 2002
Posts: 44
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.


sorry for my bad english
watch out when you're in front of my scalar howitzer smile

Punks not dead!
#19232 15/04/03 03:18 AM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
May I ask why you feel the need to run a HTTP server that has a speed of 48k/s?

#19233 15/04/03 07:46 AM
Joined: Dec 2002
Posts: 103
Vogon poet
Offline
Vogon poet
Joined: Dec 2002
Posts: 103
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.

#19234 15/04/03 09:08 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
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.

#19235 15/04/03 10:22 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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

#19236 15/04/03 12:03 PM
Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
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:

#19237 15/04/03 02:52 PM
Joined: Dec 2002
Posts: 44
G
GodGell Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Dec 2002
Posts: 44
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. (:)



sorry for my bad english
watch out when you're in front of my scalar howitzer smile

Punks not dead!

Link Copied to Clipboard