在 ATEasy 中使用 TCP

Use of TCP in ATEasy

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

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

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

没关系,我在 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)

以上每个函数都有一个 return 值,应进行检查。