3

I'm trying to write a small chat over TCP/IP in dot42 using c#. The problem is the "Net.Sockets" is missing !! It's odd because it's part of the System in C#.

using System;
using Android.App;
using Android.Os;
using Android.Widget;
using Dot42;
using Dot42.Manifest;
using System.Net;
using System.Net.Sockets; // it is not recognized !
telcom
  • 145
  • 10
  • 1
    Their site says: "The Android API is available without limitations as if it were a .NET assembly added as a reference to your project." So I reckon you can use `java.net.Socket` ? – Bart Friederichs Oct 11 '13 at 06:19
  • 1
    It should be `using Java.Net;` as in this example https://github.com/dot42/samples/blob/master/Networking/HttpServer/MainActivity.cs – ecle Oct 11 '13 at 07:13
  • See eee's comment above. – Frank Rem Oct 11 '13 at 11:35
  • using Java.Net.Socket did't work. However, as I commented to Frank the types are in the Java.Net and I don't need to import them as it's common in Java style. – telcom Oct 11 '13 at 11:51

1 Answers1

4

eee already provided a solution for your problem. Let me try to answer the question "Why is System.Net.Sockets missing?".

As Bart points out, the Android API is available without limitations. The reason is that it is an automated conversion. So it is entirely available by design.

In contrast to the Android API, the .NET API is handcrafted on top of the Android API. For example, the .NET Dictionary class is implemented as a wrapper of java.util.Map and System.String as a wrapper of java.lang.String. In other words, we take the API from .NET but the implementation from Java. This is in contrast to Mono. You will see .NET types added in new releases.

Frank Rem
  • 3,632
  • 2
  • 25
  • 37
  • I think now I got the difference. Actually now "using Java.Net" includes "socket" as a "type" not "namespace"; so I have access to socket. However, the style of C# programming can not be followed (as you mentioned it's not implemented yet). due to not having the same types available in System.Net.Socket eg:"AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp". I tried with Mono (xamarin). I can use the same code of C# and get the expected result. I'm looking forward to seeing the new releases of Dot42 soon. – telcom Oct 11 '13 at 11:50
  • 1
    One of the commenters to the question above ( : – Frank Rem Nov 06 '13 at 11:07