我想使用ATEasy
创建服务器端程序,以便ATEasy
测试将测试信息发送到将实现客户端的LABWINDOWS\CVI
。
我的问题是,是否有人在ATEasy
作为服务器使用TCP套接字时有一个很好的教程或示例?
Winsock
示例中的ATEasy
示例不够好,很难理解。
答案 0 :(得分:0)
没关系,我在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)
上述每个函数都有一个返回值,应该检查。