I'm new with Xamarin and have to create a cross platform library (iOS, Android, Win Phone). i have so much difficult to create a pcl who works for those 3 platforms. For example, this pcl needs establish a socket connection with a printer. In pcl i can't use System.Net.Sockets so my idea is create a method and tried call his code with shared project . when i execute the code, is stepped over the code inside > #if ANDROID .
public class Class1
public void socket()
Conecta.Class oi = new Conecta.Class();
public void conecta()
#if ANDROIDSystem.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient(); clientSocket.Connect("192.168.210.171", 4002); NetworkStream serverStream = clientSocket.GetStream(); byte outStream = System.Text.Encoding.ASCII.GetBytes("teste \n"); serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush();
It's just a test, the code isn't sophisticated Someone can help me? Any other idea?