首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TCP在ATEasy中的应用

TCP在ATEasy中的应用
EN

Stack Overflow用户
提问于 2015-09-30 12:45:56
回答 1查看 265关注 0票数 0

我希望使用ATEasy创建一个服务器端程序,这样ATEasy测试将向LABWINDOWS\CVI发送测试信息,LABWINDOWS\CVI将实现客户端。

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-04 07:30:35

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

例如:

代码语言:javascript
复制
    ! 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)

上面的每个函数都有一个返回值,应该进行检查。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32866494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档