0

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.

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50
Raz
  • 489
  • 3
  • 8
  • 17

1 Answers1

1

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.

Raz
  • 489
  • 3
  • 8
  • 17
  • Is it possible to copy and paste the text part of that image? It'll make it easier for others to see your answer, and it'll mean that people can search for, say, `WsAccept` and find your question and answer. Thank you. – Wai Ha Lee Oct 04 '15 at 09:04