It is not always practical or possible to use an external wireless router in order to establish a WiFi network as a base for the interprocess communication.
E.g. Android client application needs to interact with a .NET service running on the laptop anytime the laptop is turned on - it would be impractical to carry and manipulate a separate WiFi router in order to establish the network.
The solution for such scenario is to configure the virtual wireless router on the Windows machine. It means the wireless network card can be configured to act as a WiFi router.
(Of course while acting as the WiFi router it can still perform as a standard wireless network card and connect to other WiFi networks as before.)
The possibility to configure virtual wireless router comes with Windows 7 (or higher).
Also Windows Vista allows to create so called Ad-Hoc Wireless Network but it has several limitations: wireless network card cannot act as the WiFi router and as the wireless card at the same time. It means when the card is used as the router it cannot be used to connect other WiFi networks. You would need the second wireless card or to connect via the Ethernet cable. In addition when I tried it I was not able to see this Ad-Hoc network on Android device - so I was not able to use it.
Therefore this is the step-by-step procedure how to configure the virtual WiFi router in Windows 7 (or higher) and how to identify the IP address which can be then used by the service:
- Open command prompt as Administrator.
-
Create the virtual wireless network using the following command:
(When scanning WiFi the network will have name MyHotspot.)
netsh wlan set hostednetwork mode=allow ssid=MyHotspot key=password123 -
Start the virtual wireless network using the following command:
netsh wlan start hostednetwork -
Get IP address of the Windows machine (I mean this is the IP address of the Windows machine within MyHotspot network.) Run the following command:
ipconfig -all
in the list find
• Microsoft Hosted Network Virtual Adapter
• and then IPv4 Address - this is the IP address the service will use. - Use the identified IP address in the service running on Windows machine. It means the service running on the Windows machine will listen to that address (and some port).
Use the same identified IP address in the client. It means the client will open connection on that address.
(E.g. in my case the IP address was 192.168.173.1 and I chose to use the port 8094. So after modifying sources my .NET service starts listening to tcp://192.168.173.1:8094/ and my Android client opens the connection to the same address tcp://192.168.173.1:8094/)
great
ReplyDelete