我希望使用ATEasy创建一个服务器端程序,这样ATEasy测试将向LABWINDOWS\CVI发送测试信息,LABWINDOWS\CVI将实现客户端。
我的问题是,有人有关于如何在ATEasy中使用TCP套接字作为服务器的好教程或示例吗?
来自Winsock示例的ATEasy示例不够好,很难理解。
发布于 2015-10-04 07:30:35
没关系,我在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)上面的每个函数都有一个返回值,应该进行检查。
https://stackoverflow.com/questions/32866494
复制相似问题