Making the TCP/UDP Socket Samples Work a Real Phone

mango-iheart

Windows Phone 7.5 (Mango) brings us sockets as another means for us to use data from the Internet. MSDN provides two pretty sweet samples in the UDP and TCP how-to samples. Basically each sample socket connects to the TCP/IP Simple Services Echo and Quote of the Day. The samples do tell a user how to install the TCP/IP Services on their own machine to run the samples while the phone is tethered to your desktop or laptop.

Unfortunately, this does nothing for you if you want to run the samples from a physical phone that isn't tethered to your PC. You need to enter a hostname or IP that's running simple TCP services out in the wild Internet. Eerily enough, it was hard as heck to try and find a public server running simple TCP/IP Services. I binged around and even hit some internal Microsoft email lists looking for a public Microsoft owned server running simple TCP Services that I could hit for demos and such. Ah well, no luck.

But, luckily for me, my https://www.devfish.net website isn't a just a simple (ugly) IIS Web Site. Devfish is actually a Virtual Private Server from an awesome Florida based hoster, Applied Innovations. I've got a full virtual server out there I can install anything I want on. Sooo, I installed the Simple TCP/IP Services onto "devfish.net". To use the samples on a "real phone" simply point the Host Name over to "devfish.net". Done.

socket.install-tcp-services

If you want to download the samples already coded, and not have to key them in, I've shared them out at [ https://www.devfish.net/downloads/files/WP7TackleBox.zip ]. I added a few items to the samples such as saving the hostname from session to session, and trapping the socketexceptions if the host is invalid. I also chopped the SocketClient classes out to separate TCP and UCP classes.  Enjoy.

socket-menu socket-tcp socket-udp

More socket goodness and resources are available at my ScrewTurn Wiki - https://dfwiki.devfish.net  .

(I want to be a real boy! said Pinnochio)