Posted by & filed under Developer Blog.

Ever wonder who’s listening to your iTunes music when sharing it on your network? There are one or two widgets and tools made for Mac OSX that allow you to see this information, but I listen to iTunes on Windows XP. My co-worker and I were able to come up with a way to not only see who’s connected, but whether they are listening to a song, which song they are listening to, and which songs they have listened to and when. It’s not fool proof, and the data gets a little skewed when you have more than one person connected and listening. But at least you can get an idea. The process isn’t pretty, but the results are fun.

The first step is to download a simple but very handy and very free application called TCPView by Sysinternals. Once you run TCPView, you will be able to see who’s connected to iTunes and whether or not they are listening to a song. As Sysinternals website says, "TCPView is a Windows program that will show you detailed listings of
all TCP and UDP endpoints on your system, including the local and
remote addresses and state of TCP connections." One of the best features about TCPView is the icon next to the listed connection, which allows you to find the application you would like to get information for quickly at a glance. Once you get TCPView running—assuming iTunes is also running and sharing music—you will see a list of connections with the iTunes icon next to the process name (iTunes.exe) and process number. Look for TCP connections where the Remote address is something other than yourself. This means that whatever machine is listed there is at least attached to your shared music. If they press the "eject" icon next to your list of shares, they are no longer connected to you via TCP and it will not show up in TCPView even if they can still see you listed in the Shared Music list. If that same machine is listed more than once, they are not only connected to your share, but they are also listening to a song!

Now to find out the details about what song they are listening to. Using WindowsXP’s built in file search, enter "*.mp3" as all or part of the file name and ask it to look in your "My Music" directory (or wherever your music is located). Before searching, click the drop down (double down arrow) next to "When was it modified?" then select "Specify dates". In the drop list, select "Accessed Date" and put today’s date as both the "from" and the "to". Now run the search. Once the search has completed, right click one of the column headings (Name, In folder, Size, etc.) and select "More…" at the bottom of the list that opens. From that dialogue check the "Date Accessed" option, then click "OK". Now click the column heading for Date Accessed to sort the results (you may need to click twice to get the most recent at the top). Chances are, the song listed as most recent accessed is the very song being played by the machine connected to your computer! You also have a list of all the songs played today as part of your search results (obviously this includes files you have listened to as well as what others have listened to).

Windows 2k doesn’t let you see the "Date Accessed" in file search results, so it’s more difficult to know most recent songs unless you navigate through each of your songs in your music directory. You can add this column in explorer in Win2k, just not in search results. However, don’t be too sad if you are using Windows 2000, because you can have some fun that Windows XP users most likely can’t. If you are using Windows 2000, open a command prompt (Run -> cmd) and send them a system message! (For those of you who are already familiar with Windows Messaging you can stop reading here.) Do this by entering:

net send hostname write a message here

where hostname is the exact remote address listed in TCPView as the person connected (excluding port number which includes the : and everything after it. For example if you see hostname.host.com:4831 listed in TCPView, only type hostname.host.com in the command prompt) and message is whatever message you want (what do you think of that song you are listening to?). Be careful using this feature! If you forget to put the hostname you could send the message to your entire company! Try sending it to your buddy that sits next to you first so you can see what the result is like.