Click here to Skip to main content
15,879,184 members
Articles / Mobile Apps / Windows Phone 7

IP Relay for Visual Studio Mobile Device Web Development

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
16 Mar 2011CPOL2 min read 13.2K   735   9  
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.
Image 3

History

DateComments
March 16 2011First draft

License

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


Written By
R%S
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --