LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

WinScok API functions in Realtime

Hi,

 

I have the source code a dll which I am trying to port to work on a realtime PXI target.I am using VS2008, and the dll compiles fine and passes the realtime dll checker. When I deploy the dll and call it from a realtime program however, I run into problems using several windsock functions, specifically,

 

getservbyport() - generates an internal exception

gethostbyname() - fails to return a valid hostent structure - generates WSATRY_AGAIN

gethostbyaddr() - fails to return a valid hostent structure - generates WSATRY_AGAIN

 

So far I have tried linking to wsock32_rtlv.lib which comes with CVI, as well as using the winsock.h and winsock2.h headers which come with CVI.Neither has changed the situation.

 

I have tried moving the VS2008 project I have into CVI, but I have no experience with CVI and limited experience with VS2008. When I try to compile the sourcefiles in CVI I end up with a lot of errors in the standard header files, all of the form

 

"expecting ';' found ')' instead"

 

It is not clear to me why these are generated. Any help would be appreciated.

 

Jonathan Jara-Almonte

0 Kudos
Message 1 of 4
(3,659 Views)

Well it sounds as if your real-time environment does not support the WinSock functions you are trying to use. I can't help with that one.

 

CVI is an ANSI C compiler, not a C++ one. The errors you quote are typical of what happens when a C compiler tries to compile C++ code. You mention these occur in the standard headers - you should use the CVI versions of the standard headers, not ones copied from a MSVC environment. The CVI ones will have been tweaked by NI to work with plain C. If your code is written in C++ you will need to recode in C before CVI can compile it.

 

JR

0 Kudos
Message 2 of 4
(3,630 Views)

Hi,

 

Thanks for the answer on CVI. At this point, it would be far too complicated for me to try and recode the library in C, so I guess CVI is out of the question. 

 

As for the WinSock APIs, the gethostby* routines are supported by Pharlap ETS, as documented Here. Furthermore, the errors they throw as reported by WSAGetLastError() are valid errors, and do not seem to be indicative of the functions not being supported.

 

Thanks,

 

Jonathan Jara-Almonte 

0 Kudos
Message 3 of 4
(3,619 Views)

I believe I have resolved my problems with the WinSock API functions. It appears that the correct DNS server was not set, and thus the name resolution kept failing.

 

Jonathan Jara-Almotne

0 Kudos
Message 4 of 4
(3,611 Views)