socketstcplabwindowscviateasy

Use of TCP in ATEasy


I want to create a server-side program using ATEasy so that the ATEasy tests will send tests information to LABWINDOWS\CVI which will implement the client side.

My question is, does someone have a good tutorial or example on how to use TCP sockets in ATEasy as a server?

The Winsock example from the ATEasy examples isn't good enough and it is hard to understand.


Solution

  • Never Mind, i found this in the ATEASY documentation.

    enter image description here

    for example:

        ! 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)
    

    Each of the above functions has a return value and should be checked.