转MaxScript.Net接收本地端口的消息执行

Posted LGED

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了转MaxScript.Net接收本地端口的消息执行相关的知识,希望对你有一定的参考价值。

MaxScript里开不了线程,但是可以用.Net的BackgroundWorker来做后台处理 BackgroundWorker

Fn BackgroundTcpListenerDoWork theSender theEvent = 
(
    IPAddress = DotNetClass "System.Net.IPAddress"
    theIPAddress = IPAddress.Parse "127.0.0.1"
    theTcpListener = DotNetObject "System.Net.Sockets.TcpListener" theIPAddress 7457
    theTcpListener.Start()

while not theSender.CancellationPending do
    (
        theSocket = theTcpListener.AcceptSocket()
        theByteStream = DotNetObject "System.Byte[]" 8192
        theSocket.Receive theByteStream
Encoding
= DotnetClass "System.Text.Encoding" theString = Encoding.UTF8.GetString(theByteStream) if not theSender.CancellationPending do Execute theString ) theTcpListener.Stop() ) BackgroundWorker = DotNetObject "System.ComponentModel.BackgroundWorker" DotNet.AddEventHandler BackgroundWorker "DoWork" BackgroundTcpListenerDoWork BackgroundWorker.WorkerSupportsCancellation = true BackgroundWorker.RunWorkerAsync() /* BackgroundWorker.CancelAsync() BackgroundWorker.Dispose() */

 

【转】http://www.xuebuyuan.com/429604.html

以上是关于转MaxScript.Net接收本地端口的消息执行的主要内容,如果未能解决你的问题,请参考以下文章

仅在第一次运行时接收来自 Java 的 UDP 消息

服务器端口未收到 UDP 消息

什么系统是一种自动检测远程或本地主机安全性弱点的程序

linux syslog详解 转

转MSMQ 微软消息队列 简单 示例

将消息发送到套接字端口并使用Spring Integration接收响应