LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wsock32.dll equivalent in Linux

Trying to port a Windows app to Linux 64-bit app. I ported a project well into LabVIEW 2014 Beta, however there is a module that uses wsock32.dll to call the following function:

 

long setsockopt( long socket, long protocol, long selector, long *value, long size)

What is a replacement method in Linux?

Thanks

0 Kudos
Message 1 of 7
(6,368 Views)
These functions exist on Linux too (in fact WinSock is mostly ported from the BSD socket spec which is also the base for the Linux socket implementation). But not sure which .so exports them.
However there is a bigger problem here: While the names of the parameter constants look the same, their numerical values are all very different between platforms, even between different Unix flavors. Also many options are not or differently implemented between Windows and Linux/other Unixe's. I would personally bite the bullet and write a wrapper shared lib which abstracts the differences away.
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 7
(6,347 Views)

What is the name of the library in Linux? Is there an example of a wrapper?

 

Thanks!

0 Kudos
Message 3 of 7
(6,342 Views)
I don't currently have access to a computer so I can't help you about the correct .so name.

A wrapper would be simply a Dll/shared lib written in C exporting some specific function like to set a specific option:

DLLEXPORT __cdecl int SetNagleAlgo(SOCKET s, int set)
{
return setsockopt(s, SOL_TCPIP, TCP_NODELAY, set);
}

This code is just a hint, I can't easily lookup the right source code definitions here so there are certainly errors in this code.

Make it compile in the C compiler of your choice and create a shared library from it for every platform you need it.
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 7
(6,318 Views)

Could you please tell me the correct .so when you get a chance?

 

Thanks!

0 Kudos
Message 5 of 7
(6,269 Views)
Won't be before next week. Just consifder though that constants like SOL_TCPIP etc have generallt different nnumeeic values on Windows and Linux (and then again different to Free BSD Unix and others). Also the cqlling convention is likely different too, cdecl on Linux, so a solution without external wrapper will be definitly a conditional disable structure chaos.
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 7
(6,261 Views)

Checked and on Linux they seem to have wrapped all basic code into libc.so including libsocket. The only difficulty about this is that the actual libc usually is versioned and that Linux distributions don't seem to create a libc.so symbolic link at all but rather one that is a so called soname, currently libc.so.6.

Mine is libc-2.10.1.so and libc.so.6 but that is from an old Ubuntu 9 installation. Newest Linux kernels certainly will contain a default libc of 2.18 or higher.

 

Because of this and also the different numeric values of most socket constants like SOL_xxx and others between WinSock and BSD sockets, I still think trying to do this all on LabVIEW level is more pain than gain.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 7
(6,230 Views)