Welcome to the Linux community forum and interact with 2 million technical staff to access the server :? Phpset_time_limit (10); * The setting does not display any errors * error_reporting (0); functionvarinfo ($ str) {echopre; var_dump ($ str); echopre;} $ commonProtocolgetprotobyname (
Welcome to the Linux community forum and interact with 2 million technical staff> go to the server :? Php set_time_limit (10); // * The setting does not display any errors * // error_reporting (0); function varinfo ($ str) {echo "pre "; var_dump ($ str); echo "pre" ;}$ commonProtocol = getprotobyname ("
Welcome to the Linux community forum and interact with 2 million technicians>
Server:
Set_time_limit (10 );
// * The setting does not display any errors */
// Error_reporting (0 );
Function varinfo ($ str ){
Echo"
";Var_dump ($ str );
Echo"
";}
$ CommonProtocol = getprotobyname ("tcp ");
$ Socket = socket_create (AF_INET, SOCK_STREAM, $ commonProtocol );
If ($ socket ){
$ Result = socket_bind ($ socket, '192. 168.3.57 ', 192 );
If ($ result ){
$ Result = socket_listen ($ socket, 5 );
If ($ result ){
Echo "listening successful ";
}
}
} Else {
Echo "failed to listen ";
}
// $ Path = "/home/upload /";
$ Path = "e: // web //";
While (true)
{
$ Connection = socket_accept ($ socket );
If ($ connection)
{
$ Msg = "telnet succeed! \ R \ n ";
Socket_write ($ connection, $ msg, strlen ($ msg ));
$ BufferPond = array ();
$ Buffer = '';
While ($ flag = socket_recv ($ connection, $ buffer, 1024, 0 ))
{
If (false! = Strpos ($ buffer, 'filename :'))
{
$ Filename = substr ($ buffer, 9 );
$ Filename = $ path. $ filename;
$ Fp = fopen ($ filename, "wb ");
Continue;
}
Fwrite ($ fp, $ buffer );
}
Fclose ($ fp );
Socket_close ($ connection );
}
}
Socket_close ($ socket );
?>
Client:
$ Errno = '001 ';
$ Errstr = "socket file error ";
$ Fp = fsockopen ("192.168.3.57", 1337, $ errno, $ errstr, 10 );
If (! $ Fp ){
Echo "$ errstr ($ errno)
\ N ";
} Else {
$ Str = "filename: socket_file.bmp ";
Fwrite ($ fp, $ str); $ out = file_get_contents ('.../iphone3G.bmp ');
If ($ out ){
Fwrite ($ fp, $ out );
Fwrite ($ fp, 'over ');
Echo "uploaded successfully ";
}
}
Fclose ($ fp );
?>