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

  • 相关阅读:
    PHP 计算程序运行的时间
    PHP 简易版生成随机码
    PHP读取FLASH 文件信息
    MongoDB基本使用
    PHP实现QQ达人信息抓取
    bjtuOJ 1188 素数筛选
    bjtuOJ 1139 Longest Common Subsequence
    BJTU1113扫雷问题
    C#线程池的使用详解
    C#域名解析的简单制作
  • 原文地址:https://www.cnblogs.com/greencolor/p/2164427.html
Copyright © 2011-2022 走看看