亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1861 | 回復(fù): 7
打印 上一主題 下一主題

求大蝦來指導(dǎo)! [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2006-11-26 21:56 |只看該作者 |倒序瀏覽
use IO::Socket;
$sock = IO::Socket::INET->new ('172.16.6.37:80')
  or die "Socket could not be created.Because $!\n" unless $sock;
$sock->send("GET HTTP/1.1",0);

$data = <$sock>;
print $data;
close $sock;

為什么得不到服務(wù)端回顯的信息呢?
PS:新手,還望手下留情啊~~

論壇徽章:
0
2 [報告]
發(fā)表于 2006-11-26 22:23 |只看該作者

  1. $sock->send("GET / HTTP/1.1\r\nHost:172.16.6.37\r\n\r\n\r\n",0);
復(fù)制代碼

論壇徽章:
0
3 [報告]
發(fā)表于 2006-11-26 22:33 |只看該作者
謝樓上!
可以看到HTTP/1.1 200 OK的字樣了
假如我要請求一個頁面或文件,又應(yīng)該怎么寫呢?(http://172.16.6.37/test/test.html)

PS:還是沒把HTTP header看懂。

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
4 [報告]
發(fā)表于 2006-11-26 22:33 |只看該作者
原帖由 Namelessxp 于 2006-11-26 22:23 發(fā)表

  1. $sock->send("GET / HTTP/1.1\r\nHost:172.16.6.37\r\n\r\n\r\n",0);
復(fù)制代碼

\r\n 是錯誤的。是不可移植的。正確的寫法是直接用 \x0d \x0a 或者用模塊導(dǎo)出的 CRLF

論壇徽章:
0
5 [報告]
發(fā)表于 2006-11-26 22:40 |只看該作者
原帖由 flw 于 2006-11-26 22:33 發(fā)表

\r\n 是錯誤的。是不可移植的。正確的寫法是直接用 \x0d \x0a 或者用模塊導(dǎo)出的 CRLF


這個姐姐更專業(yè)!!

論壇徽章:
0
6 [報告]
發(fā)表于 2006-11-26 22:41 |只看該作者
原帖由 Namelessxp 于 2006-11-26 22:23 發(fā)表

  1. $sock->send("GET /test/test.html HTTP/1.1\r\nHost:172.16.6.37\r\n\r\n\r\n",0);
復(fù)制代碼


我照著改了一下就搞定了!!
呵呵,,

論壇徽章:
0
7 [報告]
發(fā)表于 2006-11-27 08:19 |只看該作者
原帖由 flw 于 2006-11-26 22:33 發(fā)表

\r\n 是錯誤的。是不可移植的。正確的寫法是直接用 \x0d \x0a 或者用模塊導(dǎo)出的 CRLF


這個倒沒大注意,目前不管PHP還是Perl都是在Win平臺下運行,看來是個隱患,受教

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
8 [報告]
發(fā)表于 2006-11-27 08:46 |只看該作者
原帖由 Namelessxp 于 2006-11-27 08:19 發(fā)表

這個倒沒大注意,目前不管PHP還是Perl都是在Win平臺下運行,看來是個隱患,受教

以下內(nèi)容摘錄自 perldoc perlport:
  1. Newlines

  2. In most operating systems, lines in files are terminated by newlines. Just what is used as a newline may vary from OS to OS. Unix traditionally uses \012, one type of DOSish I/O uses \015\012, and Mac OS uses \015.

  3. Perl uses \n to represent the ``logical'' newline, where what is logical may depend on the platform in use. In MacPerl, \n always means \015. In DOSish perls, \n usually means \012, but when accessing a file in ``text'' mode, STDIO translates it to (or from) \015\012, depending on whether you're reading or writing. Unix does the same thing on ttys in canonical mode. \015\012 is commonly referred to as CRLF.

  4. A common cause of unportable programs is the misuse of chop() to trim newlines:

  5.     # XXX UNPORTABLE!
  6.     while(<FILE>) {
  7.         chop;
  8.         @array = split(/:/);
  9.         #...
  10.     }

  11. You can get away with this on Unix and Mac OS (they have a single character end-of-line), but the same program will break under DOSish perls because you're only chop()ing half the end-of-line. Instead, chomp() should be used to trim newlines. The the Dunce::Files manpage module can help audit your code for misuses of chop().

  12. When dealing with binary files (or text files in binary mode) be sure to explicitly set $/ to the appropriate value for your file format before using chomp().

  13. Because of the ``text'' mode translation, DOSish perls have limitations in using seek and tell on a file accessed in ``text'' mode. Stick to seek-ing to locations you got from tell (and no others), and you are usually free to use seek and tell even in ``text'' mode. Using seek or tell or other file operations may be non-portable. If you use binmode on a file, however, you can usually seek and tell with arbitrary values in safety.

  14. A common misconception in socket programming is that \n eq \012 everywhere. When using protocols such as common Internet protocols, \012 and \015 are called for specifically, and the values of the logical \n and \r (carriage return) are not reliable.

  15.     print SOCKET "Hi there, client!\r\n";      # WRONG
  16.     print SOCKET "Hi there, client!\015\012";  # RIGHT

  17. However, using \015\012 (or \cM\cJ, or \x0D\x0A) can be tedious and unsightly, as well as confusing to those maintaining the code. As such, the Socket module supplies the Right Thing for those who want it.

  18.     use Socket qw(:DEFAULT :crlf);
  19.     print SOCKET "Hi there, client!$CRLF"      # RIGHT

  20. When reading from a socket, remember that the default input record separator $/ is \n, but robust socket code will recognize as either \012 or \015\012 as end of line:

  21.     while (<SOCKET>) {
  22.         # ...
  23.     }

  24. Because both CRLF and LF end in LF, the input record separator can be set to LF and any CR stripped later. Better to write:

  25.     use Socket qw(:DEFAULT :crlf);
  26.     local($/) = LF;      # not needed if $/ is already \012

  27.     while (<SOCKET>) {
  28.         s/$CR?$LF/\n/;   # not sure if socket uses LF or CRLF, OK
  29.     #   s/\015?\012/\n/; # same thing
  30.     }

  31. This example is preferred over the previous one--even for Unix platforms--because now any \015's (\cM's) are stripped out (and there was much rejoicing).

  32. Similarly, functions that return text data--such as a function that fetches a web page--should sometimes translate newlines before returning the data, if they've not yet been translated to the local newline representation. A single line of code will often suffice:

  33.     $data =~ s/\015?\012/\n/g;
  34.     return $data;

  35. Some of this may be confusing. Here's a handy reference to the ASCII CR and LF characters. You can print it out and stick it in your wallet.

  36.     LF  eq  \012  eq  \x0A  eq  \cJ  eq  chr(10)  eq  ASCII 10
  37.     CR  eq  \015  eq  \x0D  eq  \cM  eq  chr(13)  eq  ASCII 13

  38.              | Unix | DOS  | Mac  |
  39.         ---------------------------
  40.         \n   |  LF  |  LF  |  CR  |
  41.         \r   |  CR  |  CR  |  LF  |
  42.         \n * |  LF  | CRLF |  CR  |
  43.         \r * |  CR  |  CR  |  LF  |
  44.         ---------------------------
  45.         * text-mode STDIO

  46. The Unix column assumes that you are not accessing a serial line (like a tty) in canonical mode. If you are, then CR on input becomes ``\n'', and ``\n'' on output becomes CRLF.

  47. These are just the most common definitions of \n and \r in Perl. There may well be others. For example, on an EBCDIC implementation such as z/OS (OS/390) or OS/400 (using the ILE, the PASE is ASCII-based) the above material is similar to ``Unix'' but the code numbers change:

  48.     LF  eq  \025  eq  \x15  eq  \cU  eq  chr(21)  eq  CP-1047 21
  49.     LF  eq  \045  eq  \x25  eq           chr(37)  eq  CP-0037 37
  50.     CR  eq  \015  eq  \x0D  eq  \cM  eq  chr(13)  eq  CP-1047 13
  51.     CR  eq  \015  eq  \x0D  eq  \cM  eq  chr(13)  eq  CP-0037 13

  52.              | z/OS | OS/400 |
  53.         ----------------------
  54.         \n   |  LF  |  LF    |
  55.         \r   |  CR  |  CR    |
  56.         \n * |  LF  |  LF    |
  57.         \r * |  CR  |  CR    |
  58.         ----------------------
  59.         * text-mode STDIO
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP