[英]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)
以上每個函數都有一個返回值,應進行檢查。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.