1

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 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);
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
user976209
  • 11
  • 2
  • 4
  • Maybe this will help you out: http://stackoverflow.com/questions/3905358/how-to-ping-external-ip-from-java-android – Wesley Oct 06 '11 at 10:48

1 Answers1

0

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.

Ofir
  • 8,194
  • 2
  • 29
  • 44