android UDP connection, not receiving any data

前端 未结 1 1692
别那么骄傲
别那么骄傲 2021-01-29 02:34

Im a newbie in this so please escuse me if i ask dumb questions.

Im trying to make a UDP connection between Eclipse\'s PC Emulator & a android phone
(or between

相关标签:
1条回答
  • 2021-01-29 03:14

    After running your emulator, type it in command prompt - "telnet localhost ", then type "redir add udp:5000:6000". Connect client with port number 5000 and open udp server with port number 6000. Then you can receive client message from udp server.

    Take a look for details

    clientSocket = new DatagramSocket();
    InetAddress IPAddress = InetAddress.getByName("<pc ip>"); // instead of "localhost"
    
    
    public static final String SERVERIP = "127.0.0.1"; // 'Within' the emulator!  
    public static final int SERVERPORT = 6000;   
    
    /* Retrieve the ServerName */  
    InetAddress serverAddr = InetAddress.getByName(SERVERIP);  
    DatagramSocket socket = new DatagramSocket(SERVERPORT, serverAddr);  
    
    0 讨论(0)
提交回复
热议问题