This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

php - tcl data sending

Help for those learning Tcl or writing their own scripts.
Post Reply
p
putyn
Voice
Posts: 2
Joined: Mon Feb 07, 2011 6:39 pm

php - tcl data sending

Post by putyn »

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
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

use server socket

untested sample code i think it requires tclsh8.5 because of the clock micro

Code: Select all

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
Post Reply