I recently embarked on a project involving controlling a microcontroller remotely using wifi. Commands are sent from a windows app to a wifly shield which passes them to the mcu. The wifly shield and the computer are on the same adhoc network and i was able to ping and telnet between them successfully. The problem arises when the app throws an unknownHostException after sending the commands. I checked the ports and host name clearly and everything is ok. The app is the client while the wifly shield is the server and at the time of sending the commands the shield is up and running. Here is the TCPClient class that the app uses.
Here is the event handling part that uses the TCPClient class
The host name is ok as I got this from my router's configuration page before I switched to adhoc mode. I tried to change the port number but same result. could this be something to do with the adhoc mode as I am not familiar with it?....
Author and all-around good cowpoke
Joined: Mar 22, 2000
If the host name was "ok" then the getByName() would be able to look it up and would not be throwing the UnknownHostException.
If you can get an IP address, why not use the getByAddress( byte ) method to create an InetAddress.
Joined: Feb 16, 2012
Hi william thanks for the suggestion....I was able to connect to the device and send commands.