1

I'm trying to get a connection via TCP sockets from my Phone that is plugged via USB to the PC. It does not seem to work. The Socket.ConnectAsync returns a Success, so the hostname (name of my PC) is correctly resolved. However, the first Socket.SendAsync ends up in a Connection Reset.

It works with the emulator and if the PC and phone are in the same private WiFi network, but never via the USB connection.

This is kind of strange, since HTTP traffic seems to work quite well: The phone's browser can connect to my PC's webserver (with both PC and phone beeing offline, just connected via USB) and a small test app can connect via HTTP (WebClient) to the PC, like asked in this SO question here.

So my question is, as there must be some security restriction that I did not discover yet, or some technical restriction: How can I get it to work, and if not, why?

Thanks in advance for any help with this!

Community
  • 1
  • 1
Philip Daubmeier
  • 14,584
  • 5
  • 41
  • 77
  • Does you PC have an active firewall/Anti-Virus ? – Yahia Oct 25 '11 at 14:34
  • @Yahia: Yes, just the default windows firewall. I added a rule for the particular port, but same behaviour. To be sure I completely deactivated it, but still the same. After all, it works via WiFi, so the firewall has definitely nothing to do with it. – Philip Daubmeier Oct 25 '11 at 14:39

1 Answers1

2

Have you tried doing a connection using the Socket class to the web server (ie. port 80) on your computer?

I'm pretty sure the USB Connection Sharing for WP7 is restricted on the ports that it actually shares. I could be wrong, of course, but this would explain your situation.

Rudi Visser
  • 21,350
  • 5
  • 71
  • 97
  • Thanks for your answer! It finally led me to the cause of the problem. I set up my server at port 3000, which was for some reason blocked by the phone. Nearly every other port works, except for those that are already in use on my PC obviously and this "magical" range from 3000-3100. I could have saved a lot of time if I just tried some other port earlier... Works like a charm now! – Philip Daubmeier Oct 25 '11 at 15:04
  • how do you know the ports that are being blocked by your phone ? I have the same problem and I couldn't solve it yet – NadaNK Apr 17 '13 at 06:44
  • @NadaNaoushi Did you try using a sensible port number like 80? – Rudi Visser Apr 17 '13 at 08:24