mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#227983 01/12/10 09:24 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Hi, there

Code:
alias sockstart { 
  echo -s * Starting socket sockopen open_socket 127.0.0.1 80 
} 
on *:SOCKOPEN:open_socket: { 
  if $sockerr > 0 { 
    echo -s * Can't connect to socket. 
  } 
  else { 
    sockwrite -nt $sockname GET /socket/index.php HTTP/1.1
    sockwrite -nt $sockname Connection: Keep-Alive 
    sockwrite -nt $sockname Host: 127.0.0.1 
    sockwrite -nt $sockname $str($crlf,2) 
  } 
} 
on *:SOCKREAD:open_socket: { 
  if $sockerr > 0 { 
    echo -s * Error 
  } 
  else { 
    var %read 
    if !$sock($sockname).mark { 
      sockread %read if %read == $null { 
        sockmark $sockname 1 
      } 
    } 
    else { 
      sockread %read 
    } 
    echo -s * %read 
  } 
}


Can anyone find something bad in this script? It makes me crazy. It returns header successfully, but data can't.

/socket/index.php contains code:

Code:
<?PHP 

echo 'data'; 

?>


Regards

DeSync #227984 01/12/10 10:19 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try using HTTP/1.0 instead of HTTP/1.1 and see if that helps.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #227998 02/12/10 05:00 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Hi, I've got this:

Code:
HTTP/1.1 200 OK
Date: Thu, 02 Dec 2010 16:58:09 GMT
Server: Apache/2.2.11 (Win32) PHP/5.3.0
X-Powered-By: PHP/5.3.0
Content-Length: 7
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html


Content length is ok.

I'm using 7.15 version

Last edited by DeSync; 02/12/10 05:00 PM.
DeSync #227999 02/12/10 05:13 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You completely ignored Riamus' advice and are still using HTTP/1.1


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #228000 02/12/10 05:14 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
I'm using 1.0 but it returns 1.1.

Don't know why.

DeSync #228002 02/12/10 06:36 PM
Joined: Apr 2010
Posts: 966
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
Try something like this, just to see where you get:
Code:
alias sockopen {
  echo 12 -s * Trying to open connection with 127.0.0.1:80
  sockopen open_socket 127.0.0.1 80
}
on *:SOCKOPEN:open_socket:{
  if ($sockerr) { 
    echo 04 -s * Unable to connect: $sock($sockname).wsmsg 
  }
  else {
    echo 12 -s * Connection established.
    sockwrite -n $sockname GET /socket/index.php HTTP/1.0
    sockwrite -n $sockname Connection: Keep-Alive
    sockwrite -n $sockname
  }
}
on *:SOCKWRITE:open_socket:{
  if ($sockerr) { 
    echo 04 -s * Unable to send data through socket: $sock($sockname).wsmsg 
  }
  else {
    echo 12 -s * Send data to socket.
  }
}
on *:SOCKREAD:open_socket:{
  if ($sockerr) {
    echo 04 -s * Unable to read data from socket: $sock($sockname).wsmsg 
  }
  else {
    var %tmp
    echo 12 -s * Reading data from socket
    :loop
    sockread %tmp
    if (!$sockbr) { return }
    echo -s * %tmp
    goto loop
  }
}
on *:SOCKCLOSE:open_socket:{
  if ($sockerr) { 
    echo 04 -s * Socket closed unexpectedly: $sock($sockname).wsmsg 
  }
  else { 
    echo 12 -s * Socket closed by server. 
  }
}


Edited to add some more echos, and fix a few errors

Last edited by FroggieDaFrog; 02/12/10 06:42 PM.

I am SReject
My Stuff
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
has no one noticed this line in the original code:

Code:
sockread %read if %read == $null { 


:P


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
jaytea #228004 02/12/10 06:42 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Yeah, I saw that.

It's ok in mirc, just error in text, while copying.

jaytea #228005 02/12/10 06:43 PM
Joined: Apr 2010
Posts: 966
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
How about the /sockopen being on the same line as the /echo claiming the socket is being opened?


I am SReject
My Stuff
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Well,

All of that is copy error. Couse I've posted it on some other web and copyed to this.
So it should echo sockopen instead opening socket.

But it open socket, so it's OK.

DeSync #228009 02/12/10 11:00 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
And why sometimes responds

Connection: close

instead of

Connection: Keep-Alive


DeSync #228026 03/12/10 04:47 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
So, there's no any errors in script?

Just mIRC won't reply correctly?

DeSync #228068 04/12/10 05:15 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
blush

I've realized that there's problem with server side.
But I can't get it why. What does server side must contain?

<html> , <head> , <body> , <meta> ?

When I try some other web I get source code of it.
My current server side script is in first post above.

Regards

DeSync #228106 07/12/10 11:46 AM
Joined: Apr 2010
Posts: 30
M
Ameglian cow
Offline
Ameglian cow
M
Joined: Apr 2010
Posts: 30
The server might require more headers such as
User-Agent,Accept-Encoding, ...


m0viefreak #228108 07/12/10 12:03 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Code:
sockwrite -n $sockname GET /socket/index.php HTTP/1.0
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname User-Agent: $+(mIRC/, $version) (Windows NT; en)
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
sockwrite -n $sockname Keep-Alive: 300
sockwrite -n $sockname Accept-Language: en-us,en;q=0.5
sockwrite -n $sockname Accept-Encoding: gzip,deflate
sockwrite -n $sockname Host: 127.0.0.1 
sockwrite -n $sockname $str($crlf, 2)


This is my current header.

Last edited by DeSync; 07/12/10 12:03 PM.
DeSync #228109 07/12/10 12:12 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
And when I use this script for google.com 80 I got this:

Code:
HTTP/1.0 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Tue, 07 Dec 2010 12:10:34 GMT
Expires: Thu, 06 Jan 2011 12:10:34 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
Connection: Keep-Alive

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>


And it's good.

DeSync #228117 07/12/10 06:03 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
It's not good. You get this:
Quote:
HTTP/1.0 301 Moved Permanently
The 301 error means that the info you've requested has been moved. The http server will send you the new location in the Location field of the headers. You're supposed to get something like:
Quote:
HTTP/1.0 200 OK
to indicate the info has been successfully requested.

Tomao #228120 07/12/10 07:57 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Nevermind, I've tried other pages with 200 OK, and same. Get data, but in my case can't. We are talking here about no replying data. Just header. In this case it returns data whatever it is.

Last edited by DeSync; 07/12/10 08:00 PM.
DeSync #228220 12/12/10 03:15 PM
Joined: Jan 2008
Posts: 57
D
DeSync Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Jan 2008
Posts: 57
Is it against of rules of board to BUMP?

DeSync #228224 12/12/10 03:49 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
It's your server-side to blame. You can't possibly get help from people who are clueless as to what setup you have of your source or the data you try to get the info from.

Page 1 of 2 1 2

Link Copied to Clipboard