|  | 
| | 
 
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
Hi, there  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:  Regards  |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2004 Posts: 8,061 Hoopy frood |  
|   Hoopy frood Joined:  Oct 2004 Posts: 8,061 | 
Try using HTTP/1.0 instead of HTTP/1.1 and see if that helps. |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
Hi, I've got this: 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/htmlContent length is ok. I'm using 7.15 version
Last edited by DeSync; 02/12/10 05:00 PM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2003 Posts: 3,641 Hoopy frood |  
|   Hoopy frood Joined:  Oct 2003 Posts: 3,641 | 
You completely ignored Riamus' advice and are still using HTTP/1.1 |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
I'm using 1.0 but it returns 1.1.
 Don't know why.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2010 Posts: 964 Hoopy frood |  
|   Hoopy frood Joined:  Apr 2010 Posts: 964 | 
Try something like this, just to see where you get: Edited to add some more echos, and fix a few errorsalias 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. 
  }
}
Last edited by FroggieDaFrog; 02/12/10 06:42 PM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2006 Posts: 523 Fjord artisan |  
|   Fjord artisan Joined:  Feb 2006 Posts: 523 | 
has no one noticed this line in the original code: 
sockread %read if %read == $null { 
:P |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
Yeah, I saw that.
 It's ok in mirc, just error in text, while copying.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2010 Posts: 964 Hoopy frood |  
|   Hoopy frood Joined:  Apr 2010 Posts: 964 | 
How about the /sockopen being on the same line as the /echo claiming the socket is being opened? |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
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
 |  
| DeSync | 
And why sometimes responds
 Connection: close
 
 instead of
 
 Connection: Keep-Alive
 
 
 |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
So, there's no any errors in script?
 Just mIRC won't reply correctly?
 |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
 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 |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2010 Posts: 30 Ameglian cow |  
|   Ameglian cow Joined:  Apr 2010 Posts: 30 | 
The server might require more headers such asUser-Agent,Accept-Encoding, ...
 
 
 |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
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
 |  
| DeSync | 
And when I use this script for google.com 80 I got this: 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. |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2007 Posts: 1,124 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2007 Posts: 1,124 | 
It's not good. You get this: HTTP/1.0 301 Moved PermanentlyThe 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: to indicate the info has been successfully requested. |  |  |  
| 
| 
|  |  
| 
DeSync
 |  
| DeSync | 
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
 |  
| DeSync | 
Is it against of rules of board to BUMP? |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2007 Posts: 1,124 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2007 Posts: 1,124 | 
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. |  |  |  
 | 
 | 
| 
 |