All pastes #478739 Raw Edit

Stuff

public php v1 · immutable
·published 2007-05-09 10:46 UTC
rendered paste body
TCL:set port 7801 proc localsockfree {sock} {  if {[catch {socket -server {} $sock} rc]} {    return 0  } else {    # server could be started, so the port is not in use locally    catch {close $rc}    return 1  }}  proc accept {chan addr port} {  fconfigure $chan -blocking 0 -buffering line  fileevent $chan readable [list getlines $chan $addr $port]} proc getlines {chan addr port} {  global mysql  set string [gets $chan]  puts $chan "$string recieved"}  # start socket server and wait... :>if {[localsockfree $port]} {  socket -server accept $port} { return "port $port already used.." }PHP:<?php$fp = fsockopen("192.168.1.1", 7801);if (!$fp) {    echo "Unable to open\n";} else {    fwrite($fp, "GET test\r\n");    stream_set_timeout($fp, 2000);    $res = fread($fp, 2000);    $info = stream_get_meta_data($fp);    fclose($fp);    if ($info['timed_out']) {        echo 'Connection timed out!';    } else {        echo $res;    }}?>