| View previous topic :: View next topic |
| Author |
Message |
putyn Voice
Joined: 07 Feb 2011 Posts: 2
|
Posted: Tue Feb 08, 2011 12:27 pm Post subject: php - tcl data sending |
|
|
ok as i was advised i opened a new topic and ill explain here what i want to do
i want to open a connection from a php script to my eggdrop bot and to send some data (text) to the bot and the bot after reads the data will have to send some data (text) back
now i know how send text to the bot from php what i can't figure out how to send data from the bot using the connection made by the php script
any ideas are appreciated |
|
| Back to top |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Tue Feb 15, 2011 9:58 am Post subject: |
|
|
use server socket
untested sample code i think it requires tclsh8.5 because of the clock micro
| Code: | proc server_app {s cli_addr cli_port} {
while {![eof $s]} {
flush $s
gets $s buf
append new_buf $buf\n
}
if {[info exists new_buf]} {
if {![string equal {} $new_buf]} {
set micro [clock micro]
if {![catch {open /tmp/blah.${micro} w} wf]} {
puts $wf $new_buf
putlog "wrote data to /tmp/blah.${micro} received from $cli_addr on port $cli_port"
close $wf
}
}
}
close $s
}
socket -server server_app 65000 |
_________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
|