Note that there are some explanatory texts on larger screens.

plurals
  1. POCommunication between android tablet and PC
    text
    copied!<p>I am starting on Android and in my first application I need to establish a communication between and android table a PC. The communication is direct by staqtic IPs as I need that when I have several PCs and tablets each table only communicates with its PC.</p> <p>The communication from the tablet to the Pc is already working but from the PC to the table I cannot get data transfered</p> <p>Android side</p> <pre><code>public class Server implements Runnable { @Override public void run() { while (always==true) { while(start2==false) { } try { InetAddress serverAddr = InetAddress.getByName("192.168.173.133"); updatetrack("\nServer: Start connecting\n"); //*DatagramSocket socket = new DatagramSocket(SERVERPORT2, serverAddr);/ DatagramSocket socket = new DatagramSocket(SERVERPORT2); byte[] buf = new byte[17]; DatagramPacket packet = new DatagramPacket(buf, buf.length, serverAddr, SERVERPORT2); //*DatagramPacket packet = new DatagramPacket(buf, buf.length);/ updatetrack("Server: Receiving\n"); socket.receive(packet); updatetrack("Server: Message received: '" + new String(packet.getData()) + "'\n"); updatetrack("Server: Succeed!\n"); start2=false; } catch (Exception e) { updatetrack("Server: Error!\n"); start2=false; } } } } </code></pre> <p>192.168.173.133 is the table IP and SERVERPORT2 is 4445 When I start the application it remains waiting for data after displaying "Server: Receiving" but </p> <p>C# code</p> <pre><code>public static void Main() { IPEndPoint iep2 = new IPEndPoint(IPAddress.Parse("192.168.173.133"), 4445); string hostname = Dns.GetHostName(); byte[] data = Encoding.ASCII.GetBytes(hostname); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); sock.SendTo(data, iep2); sock.Close(); } </code></pre> <p>I suppose that it is any silly think I am forgotten but after reading many forums and books I am stopped on this point</p> <p>Any advise will be welcome</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload