[Mono-list] Native UDP socket close problem when calling C/C++ shared lib from C#/Mono
edwin
nospamhere_email at comcast.net
Thu Oct 21 19:12:24 EDT 2010
Hello,
I have searched this forum and the web using Google to try to find the
answer to my issue but I failed. That is why I am posting here. Thank you in
advance for any help.
Problem:
-- Native UDP socket bind errors --
I have a native shared VOIP library that has been ported to Ubuntu Linux
10.04 from Windows. The shared native C/C++ library has a managed wrapper
that allows C#/Mono code to call into the native shared library. Everything
is working quite well…
However, when running the managed code C# test driver application I
developed to test/verify everything, I am experiencing UDP port bind errors.
I get the same UDP port bind errors when I run under the Monodevelop soft
debugger and from a terminal.
Basically in the native code shared library, a UDP SIP port is opened, then
used, and finally closed. When I want to use the SIP port again (by calling
into the native shared library) to open and bind to the SIP port, my native
code shared library cannot bind to the port and it then return its “cannot
bind to port” error indication.
Upon further investigation, I see that when the UDP port gets closed by the
native code, the UDP port is still shown to be in use by the system. If I
open the SIP UDP port and then close it, the socklist script available on
Ubuntu shows that the port (5092 in this case) has a pid and an fd of zero
and there is no process name. Here is the output from socklist after a
simple SIP port open and close for UDP port 5092:
type port inode uid pid fd name
tcp 34771 75589 1000 17093 50 monodevelop
tcp 22 4602 0 0 0
tcp 631 7595 0 0 0
tcp 445 4016 0 0 0
tcp 139 4018 0 0 0
tcp 34771 75590 1000 17093 53 monodevelop
tcp 56021 60469 1000 17093 42 monodevelop
tcp 45705 75333 1000 17093 51 monodevelop
tcp 44527 0 0 0 0
tcp 57580 75653 1000 25002 3 mono
tcp 58243 59112 1000 17093 41 monodevelop
tcp 44841 67587 1000 17093 49 monodevelop
tcp 51347 61611 1000 17093 45 monodevelop
tcp 57297 65433 1000 17093 46 monodevelop
tcp 56398 58899 1000 17093 43 monodevelop
udp 55625 75721 1000 25002 5 mono
udp 5090 75738 1000 25002 6 mono
udp 5092 75760 1000 0 0
udp 5353 3928 110 0 0
udp 45942 3929 110 0 0
udp 137 4655 0 0 0
udp 137 4652 0 0 0
udp 138 4656 0 0 0
udp 138 4653 0 0 0
Apparently the system still thinks the UDP socket is being used even though
it has been closed by the native code on behalf of the C#/Mono managed code
test application. Hmmm…. Stange... I see no native socket close errors being
reported.
One other item I would like to mention – When I execute this same managed
code and native shared library using CodeBlocks IDE (and the typical GNU
tool chain and gdb debugger) everything executes without issue. Hmmm…..
Any help would be very much appreciated. The mono project is very cool.
Thank you,
edwin
--
View this message in context: http://mono.1490590.n4.nabble.com/Native-UDP-socket-close-problem-when-calling-C-C-shared-lib-from-C-Mono-tp3006468p3006468.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list