[Mono-bugs] [Bug 666736] UDP support

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 23 22:21:27 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=666736

https://bugzilla.novell.com/show_bug.cgi?id=666736#c3


Jonathan Pryor <jpryor at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jpryor at novell.com
         Resolution|                            |WONTFIX

--- Comment #3 from Jonathan Pryor <jpryor at novell.com> 2011-02-24 03:21:26 UTC ---
Unfortunately, I don't believe this can be fixed.

Playing along at home... I took the HelloWorld sample:

  https://github.com/mono/monodroid-samples/tree/master/HelloWorld

and changed HelloWorld.cs to the attached file.

Then I altered System.dll's System.Net.Socket(AddressFamily, SocketType,
ProtocolType) constructor to skip the NET_2_1 checks:

https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.Sockets/Socket_2_1.cs#L853

changing line 855 to `#if false` and line 892 to `#if true`, then rebuilt [0],
and deployed the app.

Result: 

E/mono    (30430): Unhandled Exception: System.Net.Sockets.SocketException:
Access denied
E/mono    (30430):   at System.Net.Sockets.Socket..ctor (AddressFamily family,
SocketType type, ProtocolType proto) [0x00000] in <filename unknown>:0 
E/mono    (30430):   at System.Net.Sockets.UdpClient.InitSocket
(System.Net.EndPoint localEP) [0x00000] in <filename unknown>:0 
E/mono    (30430):   at System.Net.Sockets.UdpClient..ctor (Int32 port)
[0x00000] in <filename unknown>:0 
E/mono    (30430):   at Mono.Samples.HelloWorld.HelloAndroid.OnCreate
(Android.OS.Bundle savedInstanceState) [0x00000] in <filename unknown>:0 
E/mono    (30430):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_
(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState)
[0x00000] in <filename unknown>:0 
E/mono    (30430):   at (wrapper dynamic-method)
object:ac7d78cd-1850-4e75-a6e6-8171819ec971 (intptr,intptr,intptr)

This strongly suggests that, at least at this point in time, the Android
operating system denies access to UDP sockets, and thus this cannot be fixed.

[0] Yes, you too can replace runtime assemblies!

But only for Release builds, not Debug builds.

First, download, configure, and build mono 2.10:

    git clone git at github.com:mono/mono.git
    cd mono
    git checkout -t origin/mono-2-10
    ./autogen.sh --with-monodroid=yes # ...
    make
    # get some coffee....

Once done, you can edit the files in e.g. mono/mcs/class/System, then rebuild
System.dll for the MonoDroid profile:

    cd mcs/class/System/
    make PROFILE=monodroid

The resulting assembly is in e.g. mono/mcs/class/lib/monodroid/System.dll.

Next, replace the System.dll in your SDK installation with your new assembly,
e.g. in:

  C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework\MonoDroid\v1.0

Then, open up your HelloWorld project and build a Release build (and make sure
that the shared runtime is disabled). This will pull in (and link) the
assemblies in the above SDK installation directory, thus using your updated
version. (Debug builds use the copy in Mono.Android.DebugRuntime-debug.apk, and
thus can't be replaced.)

Of course, this isn't officially supported, you may break things (and keep both
halves!), etc., etc.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list