antiufo Posted April 26, 2007 Share Posted April 26, 2007 I'm working on a script to easily send files to people by sending an URL with my IP and filename, for exampleI can give someone an URL like http://87.14.27.88/file1.rarand let someone download it via http with any browser.The download begins (I see the progress window) but it is impossible to get the file (speed 0)expandcollapse popupIf $CmdLine[0]=0 Then Exit $file=$CmdLine[1] TCPStartup() $s=TCPListen(@IPAddress1, 80) $httpAcceptSocket=-1 While 1 If $httpAcceptSocket=-1 Then TCPCloseSocket($httpAcceptSocket) Sleep(100) $httpAcceptSocket=TCPAccept($s) If $httpAcceptSocket<0 Then ContinueLoop $r=TCPRecv($httpAcceptSocket, 1024) $cmd=StringLeft($r, StringInStr($r, ' ')-1) If $cmd<>'GET' Then ContinueLoop ;$file=StringTrimLeft(StringLeft($r, StringInStr($r, 'HTTP')-2), 5) ; $file is now "/file.rar" ;If Not $file Then ContinueLoop ;If Not FileExists($file) Or StringInStr(FileGetAttrib($file), 'D') Then ContinueLoop ;MsgBox(0,0,$file) TCPSend($httpAcceptSocket, _ 'HTTP/1.1 200 OK' & @CRLF & _ 'Date: Wed, 25 Apr 2007 18:14:19 GMT' & @CRLF & _ 'Server: Apache' & @CRLF & _ 'Last-Modified: Fri, 20 Apr 2007 10:13:09 GMT' & @CRLF & _ 'ETag: "3f21b12-3b729-46289235"' & @CRLF & _ 'Accept-Ranges: none' & @CRLF & _ 'Content-Length: 243497' & @CRLF & _ 'Connection: close' & @CRLF & _ 'Content-Type: application/octet-stream' & @CRLF) TCPSend($httpAcceptSocket, FileRead($file)) WEnd TCPShutdown()Can someone help me to find the error? (Probabily on the last TCPSend)Thanks. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 26, 2007 Share Posted April 26, 2007 seems like maybe your loop never ends? Also about sending the file all at once tipically when i did this it would fail if the data to send was much over 100mb... don't know why, but somthing to think about... Link to comment Share on other sites More sharing options...
antiufo Posted April 27, 2007 Author Share Posted April 27, 2007 I just want to use it to send sometimes small files to one person. Yes, the loop never ends, I forgot to add an hotkey or something like it (this is not the final version) Should I send any special character after the HTTP header or something like that? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now