Can i ping to my PC from my mobile and Vice versa?
My android mobile and PC are connected using USB. Now can i ping to my PC from my mobile?Is this possible? And also can i ping to my mobile from PC? If so, using what IP, i should ping my Mobile? Note:
- My HTC mobile and PC are not in same network.
- HTC mobile have开发者_StackOverflow社区 GSM net connection.
- Below i have added my sample code to ping PC and HTC mobile
Eg:
client code:
Socket socket = new Socket("10.51.2.98", 1234);//trying to ping my PC ip address
server code:
channel.sin_family = AF_INET;
channel.sin_addr.s_addr = INADDR_ANY;
channel.sin_port = htons(1234);
1st - your code would not ping anywhere - but rather create a TCP socket (see ICMP).
2nd - USB does not usually give you a network interface (it is possible, but rarely the default type of connection), but some other profile such as mass storage device, and you need a networking interface to generate ping messages.
精彩评论