zoukankan      html  css  js  c++  java
  • socket client with proc

    Server:

    set socket ""
    proc acceptSocketConnection { a_sock an_addr a_port } {
           global socket
           set socket $a_sock
            fconfigure $socket -buffering line -translation lf -blocking 0 -buffersize 72000
            fileevent $socket readable processMessage
            set ready 1
            set datestamp 20110901
     if { ![regexp -nocase windows $::tcl_platform(os)] } {
     set l_genfile [file join [pwd] "strubio_${datestamp}.gen"]
     puts $socket "GEN $l_genfile"
     set l_matfile [file join [pwd] "strubio_${datestamp}.mat"]
     puts $socket "NEW $l_matfile"
     puts $socket "NEW $l_matfile"
           
       }
    }

    proc processMessage { } {
        global socket
        gets $socket l_message
        if {$l_message != ""} {
           puts $l_message
           }
       
    }


    set server [socket -server acceptSocketConnection -myaddr 127.0.0.1 2200]
    vwait forever

    Client:

    set ::stru_pipe ""


    set ::stru_executable "~/Documents/bin/osflm"
    set l_sumfile "/home/g/Documents/parttest/stru_20110902_145832.sum"
    set l_spotodfile "/home/g/.stru/stru_20110902_145832.spotod"
    set l_coordsfile "/home/g/Documents/parttest/stru_20110902_145832.coords"


    set ::stru_pipe [open "|\"$::stru_executable\" SUMMARY $l_sumfile SPOTOD $l_spotodfile COORDS $l_coordsfile MOSFLMSOCKET 2200"]
    fileevent $::stru_pipe readable outputsinfo
    proc outputsinfo { } {
            global ::stru_pipe
     gets $::stru_pipe linemess
            puts $linemess
    }
    vwait forever

  • 相关阅读:
    广度优先搜索(一)
    快速幂
    office 2013
    最著名的十大公式
    二分查找的上下界
    双关键字快速排序
    字符串操作
    分治算法练习(二)
    P3119 [USACO15JAN]草鉴定[SCC缩点+SPFA]
    P3225 [HNOI2012]矿场搭建[割点]
  • 原文地址:https://www.cnblogs.com/greencolor/p/2164427.html
Copyright © 2011-2022 走看看