using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Java.IO;
using System.Net.Sockets;
using Java.Net;
using Android.Util;
namespace TEST1
{
public class Socet_String :Java.Net.Socket
{
public string SERVER_IP;
public int SERVER_PORT;
protected BufferedReader OKU;
protected BufferedWriter YAZ;
protected Context CON;
public Socet_String(string IP,int PORT,Context con)
{
this.Connect(new InetSocketAddress(IP,PORT));
this.SERVER_IP=IP;
this.SERVER_PORT=Port;
this.OKU=new BufferedReader(new
Java.IO.InputStreamReader(this.InputStream,"UTF-8"),1024);
this.YAZ=new BufferedWriter(new
Java.IO.OutputStreamWriter(this.OutputStream,"UTF-8"),1024);
}
public string Sent(string komut)
{
this.YAZ.Write(komut);
this.YAZ.Flush();
return OKU.ReadLine();
}
public override void Close ()
{
OKU.Reset();
YAZ.Flush();
OKU.Close();
YAZ.Close();
base.Close ();
}
public bool isBaglantiDurumu {
get{return isOnlineConnection();}
set{isBaglantiDurumu=value;}
}
public bool isOnlineConnection()
{
Android.Net.ConnectivityManager
conm=(Android.Net.ConnectivityManager)
this.CON.GetSystemService(Context.ConnectivityService);
Android.Net.NetworkInfo i=conm.ActiveNetworkInfo;
if(i==null || !i.IsConnected || !i.IsAvailable)
return false;
return true;
}
public static bool isOnlineConnection(Context cnt)
{
Android.Net.ConnectivityManager
conm=(Android.Net.ConnectivityManager)
cnt.GetSystemService(Context.ConnectivityService);
Android.Net.NetworkInfo i=conm.ActiveNetworkInfo;
if(i==null || !i.IsConnected || !i.IsAvailable)
return false;
return true;
}
public static string MachAddress()
{
String macAddress = String.Empty;
try
{
foreach (System.Net.NetworkInformation.NetworkInterface
networkInterface in
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
{
try
{
if
(!String.IsNullOrEmpty(networkInterface.GetPhysicalAddress().ToString()) &&
!networkInterface.GetPhysicalAddress().ToString().StartsWith("0000"))
{
macAddress +=
(networkInterface.GetPhysicalAddress().ToString()) + "-";
}
}
catch { }
}
if (!String.IsNullOrEmpty(macAddress))
{
if (macAddress.EndsWith("-"))
{
macAddress = macAddress.Substring(0,
macAddress.Length - 2);
}
}
}
catch (Exception ex)
{
System.Diagnostics.StackTrace stackTrace = new
System.Diagnostics.StackTrace();
String method = stackTrace.GetFrame(0).GetMethod().Name;
Log.Error("HATA " + method + ":", ex.Message +
System.Environment.NewLine + ex.StackTrace.ToString());
}
if (string.IsNullOrEmpty(macAddress))
{
macAddress = "none";
}
return macAddress;
}
public static string MachLocal_IP()
{
String macAddress = String.Empty;
try
{
foreach (System.Net.NetworkInformation.NetworkInterface
networkInterface in
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
{
try
{
if
(!String.IsNullOrEmpty(networkInterface.GetIPv4Statistics().ToString()) &&
!networkInterface.GetIPv4Statistics().ToString().StartsWith("0000"))
{
macAddress +=
(networkInterface.GetIPv4Statistics().ToString()) + ".";
}
}
catch { }
}
if (!String.IsNullOrEmpty(macAddress))
{
if (macAddress.EndsWith("."))
{
macAddress = macAddress.Substring(0,
macAddress.Length - 2);
}
}
}
catch (Exception ex)
{
System.Diagnostics.StackTrace stackTrace = new
System.Diagnostics.StackTrace();
String method = stackTrace.GetFrame(0).GetMethod().Name;
Log.Error("HATA " + method + ":", ex.Message +
System.Environment.NewLine + ex.StackTrace.ToString());
}
if (string.IsNullOrEmpty(macAddress))
{
macAddress = "none";
}
return macAddress;
}
}
}
I could not understand why this class is compiled, errors? could help will
be very happy. Thanks in advance ...
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Socket-Problem-tp5622204p5622204.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid