LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Internet Library/Telnet. delay in InetTelnetWrite

Solved!
Go to solution

Hello there

 

I have set up a Telnet Echo Server on a FPGA and i want to communicate with it using CVI and the Internet/Telnet library. It works fine so far, but between reading the echo response and sending the next information, there is a delay of 25 seconds (i monitor the traffic with wireshark). What could cause this delay?


#include <utility.h> 
#include <cvintwrk.h>
#include <cvirte.h>
#include <userint.h>
#include <ansi_c.h>

static int gTelnetHandle = -1;
static int gResult = -1;

 

void main(void)
{
 unsigned long i=0;
 const char data[31]="Hallo";
 const char data2[31]="Ollah die Waldfee";

 char readBuffer[256];
 int bytesRead;
 
 //open telnet
 gTelnetHandle = InetTelnetOpen ("192.168.1.10", 7, 0);

 gResult = InetTelnetWrite (gTelnetHandle, data, "\r\n", 6, 0, 25000);
 gResult = InetTelnetRead (gTelnetHandle, readBuffer, 10, &bytesRead, 25000);

 

 // it takes 25 seconds until i can see (in wireshark) that he has sent this packet after received the echo, read by the line above.

 gResult = InetTelnetWrite (gTelnetHandle, data2, "\r\n", 17, 0, 25000);
 gResult = InetTelnetRead (gTelnetHandle, readBuffer, 17, &bytesRead, 25000); 
 
 //close telnet
 gResult = InetTelnetClose (gTelnetHandle);

}


 

 

Regards Florian

0 Kudos
Message 1 of 5
(3,799 Views)
Solution
Accepted by topic author floGzmo

Just a wild guess here, but I'd say that the 25 second delay is probably related to the 25000 ms timeout you have programmed.Smiley Very Happy

 

JR

0 Kudos
Message 2 of 5
(3,796 Views)

Smiley Sad Shame on me. I guess you are right.

 

But how can i realize to answer right after receiving a packet. I think its not possible to respond dynamically. In the telnet example provided, ther is a static timeout of 100ms.

"error = InetTelnetRead (gTelnetHandle, response, sizeof (response) - 1, &bytesRead, 100);"

 

Thank you for your help and fast response.

 

Greetings Florian

0 Kudos
Message 3 of 5
(3,789 Views)

I should start by saying that I have not used the CVI Telnet library before.

 

However, I notice that the help for the Open function says that the normal Telnet port is 23; you seem to have used port 7 in your posted code. Is this to match your FPGA implementation or could it be a typo?

 

I suspect you should use the -1 option to define the string lengths to the Write function - you have set a value of 6 in your first write, for a string containing 5 characters. I don't know if this would cause any problems.

 

If you had used a variable to receive the number of bytes actually written, instead of the NULL option you have chosen, you should be able to tell if the bytes were sent correctly or not.

 

JR

0 Kudos
Message 4 of 5
(3,780 Views)

Yes in the FPGA Telnet Echo Server example the port 7 is used, but its configurable. Port 7 is the Echo port.

 

The value 6 or 17 for the bytes to write was just to test it. I thought that i have to set 6 because of 5 bytes "Hallo" and 1 byte "\0". I will use -1 as you mentioned, because the strings are \0 terminated. I will also implement the usage and check of *bytesWritten.

 

greetings Florian

0 Kudos
Message 5 of 5
(3,770 Views)