<?php $srv _ip = ' 192.168.1.5 ';//your target service address. $srv _port = 80;//Port $url = ' http://localhost/fsock.php '; Receive the URL specific address of your post $fp = '; $errno = 0;//error Handling $errstr = ';//error handling $timeout = How long has 10;//been interrupted without a connection? $post _str = "Username=demo&password=hahaha";//what to submit. Open the Socket link for the network. $fp = Fsockopen ($srv _ip, $srv _port, $errno, $errstr, $timeout); if (! $fp) { Echo (' FP fail '); } $content _length = strlen ($post _str); $post _header = "Post $url http/1.1rn"; $post _header. = "CONTENT-TYPE:APPLICATION/X-WWW-FORM-URLENCODEDRN"; $post _header. = "User-agent:msiern"; $post _header. = "Host:". $srv _ip. " RN "; $post _header. = "Content-length:". $content _length. " RN "; $post _header. = "Connection:closernrn"; $post _header. = $post _str. " Rnrn "; Fwrite ($fp, $post _header); $inheader = 1; while (!feof ($fp)) {//test file pointer to location at end of file $line = fgets ($fp, 1024); Remove header information from the request package if ($inheader && ($line = = "N" | | | $line = = "RN")) { $inheader = 0; } if ($inheader = = 0) { Echo $line; } } Fclose ($FP); Unset ($line); ?> |