Click here to Skip to main content
Click here to Skip to main content

IP Relay for Visual Studio Mobile Device Web Development

, 16 Mar 2011
Rate this:
Please Sign up or sign in to vote.
Enable access from mobile phone emulator to Visual Studio WebDev.WebServer listening on localhost

The Problem

Have you tried to develop a mobile device application that is using web services? If you did and if you had the web service running on your localhost WebDev.WebServer.EXE, then you may have found out that the web service is only listening to 127.0.0.1 IP address and there is no way you can connect from the mobile device emulator to the web service (because the device 127.0.0.21 is its internal address). I am guessing that MSFT didn’t want developers to use their development environment for commercial use so the access from the network is blocked.

So you have a mobile device application that is using web service and you don’t have IIS or other web server to run your service. I have searched the net for an answer and found nothing!

The Solution

Build a small software relay (IPRelay) that will relay any socket connections to your network address to your local host.

IPRelay/IPRelay01.jpg

GUI Details

The IPRelay has a very simple and minimal GUI that allows changing the IP address and port of the “Listen” and “Forward to” note that the “Listen” address would be your computer external address (or name) and the “Forward to” will point to your web service. The Trace checkbox, when checked, will print all the data coming from the device on the left and all the data sent back on the right. Clear button is used to clear the trace data from both text boxes and the Start button is used to start and stop the routing. Note that all caught exceptions are logged into the right text box.

IPRelay/IPRelay03.jpg

How Does It Work?

  • The IPRelay listens to incoming socket connections on the “Listen” IP & Port.
  • For every new connection, a new Relay class is created.
  • This class creates a socket connection to the “Forward to” IP & Port then it creates 2 threads that are listening for incoming socket data from both sockets.
  • Whenever data is received by each socket, it is immediately forwarded to the other socket.

History

Date Comments
March 16 2011 First draft

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

R%S

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 16 Mar 2011
Article Copyright 2011 by R%S
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid