what does "sockitsendnrecv" mean?
robin
sockitsendnrecv/TIME=0.3 socknum, command, outputarray
sockitsendnrecv/TIME=.001 socknum, "waitcomplete()\n", garbage
Those two programs is what mean.
Is mainly "sockitsendnrecv/TIME" how to use?
I do not find it explain in Igor pro manual.
The help file sockit says
SOCKITsendnrecv [/FILE=filenameStr/TIME=timeout /SMAL/NBYT=numbyteExpected] socketID, msgStr [,outputStr]
a synchronous way of sending and receiving messages with a TCP/IP network socket.
Flags
/FILE=fileNameStr the received messages from the socket connection are put into a file
/TIME=timeout the send will wait for a maximum of timeout seconds before timing out. To ensure that all data is received in a single call to the operation the XOP waits for a maximum of timeout seconds for successive reads from the socket. This means that although the first and subsequent reads may happen quickly, when the last data has been received there is a delay of timeout seconds before the XOP returns. The XOP will therefore take a minimum of timeout seconds. If you do not want this to happen, because the message is small, then use the /SMAL flag. If the /TIME flag is not specified then timeout defaults to 1 second.
/SMAL If a small reply is expected (<4096 characters) then only a single read of the socket is carried out by the operation. i.e. the read will still wait for a maximum of timeout seconds, but it won't wait to see if there is going to be more to come.
/NBYT = numbyteexpected If you are expecting a message of known length then the operation will finish as soon as numbyteexpected are received. Any bytes received over this limit will be placed in the buffer for this socket AND NOT be seen in outputStr
Main keywords
sockitID - A user defined variable or NVAR that is used to refer to the open connection.
msgStr - the message you are trying to send to socketID. (msgStr is limited to 4096 characters)
outputStr - if the optional outputStr is specified then the returned message from the server is put into this string. It must be a local string variable or SVAR. Using outputStr is the only way to ensure that incoming binary data is handled properly. Whilst S_tcp is always created it doesn't handle binary data well.
Variables and Strings
The SOCKITsendnrecv operation returns information in the following variables:
V_flag V_flag is set to 0 if the message was sent and received successfully, or to 1 if the operation failed.
S_tcp This string contains the message that was received from socketID. Doesn't handle binary data properly, unlike outputStr.
Other details
As well as putting the data into outputStr/S_tcp and/or a file, the output is also placed into the bufferwave associated with the socket. However, any associated Processors are NOT called. This is because the processor function could also have a SOCKITsendnrecv operation which would lead to recursion. You are responsible for tokenizing the reply and calling any processor functions yourself.
This function differs from the normal socket communication in that the received messages are collected directly after the sent message, i.e. synchronized transmission.
Example
variable sockNum = 0
make/t bufferwave
sockitopenconnection/proc=myprocessorFunc sockNum,"www.wavemetrics.com",80,bufferwave
//now get the webpage
sockitsendnrecv/TIME=2 sockNum,"GET / \r\n"
print S_tcp
Andy
March 26, 2018 at 02:21 pm - Permalink
March 26, 2018 at 06:48 pm - Permalink