0

我想创建一个服务器端程序,ATEasy以便ATEasy测试将测试信息发送到LABWINDOWS\CVI将实现客户端的测试信息。

我的问题是,有人有关于如何将 TCP 套接字ATEasy用作服务器的好的教程或示例吗?

Winsock示例中的示例ATEasy不够好,很难理解。

4

1 回答 1

1

没关系,我在 ATEASY 文档中找到了这个。

在此处输入图像描述

例如:

    ! create the socket in TCP mode
    asASocket = WsCreate(aWsTcpIp)

    ! Attach the socket
    WsBind(asASocket,"12345" ,"127.0.0.1")

    ! Set the Socket to listen for an incoming connection from a client:
    WsListen(asASocket)

    ! Attempts to return a readwrite socket to the remote client in twenty seconds. 
    ! In this stage the client should be calling WsConnect()...
    newSocket=WsAccept(asASocket,20000) 

    ! Notice that we send ( and receive ) data with the new socket that was returned by WsAccept
    WsSend(newSocket,300, ,"HELLO, HOW ARE YOU?")

    ! Attempt to Receive data from the client
    ! the client should send a message using WsSend()...
    while True
    if WsReceive(newSocket, 1000, , sMessage)>0
        exitloop
    endif 
    endwhile

    ! print the message from the client
    print sMessage

    ! close the connection
    WsClose(newSocket)
    WsClose(asASocket)

上述每个函数都有一个返回值,应该检查。

于 2015-10-04T07:30:35.653 回答