Socket connection in .net CF

Hi,

I'm trying to establish a simple socket connection between my pc (server) and my HP ipaq (client). I downloaded the sample synchronous server and client programs from the msdn. The programs work fine when both the server and client are running in the PC. However, when I run the client proggram in the pocket pc, it throws a socket exception. Can you tell why it happens.

Also, my device gets connected to the internet using Wi-fi connection. But the moment I use a USB cable to connect it to my PC, to deploy my program and test it, the wi-fi connections get disabled. Only the ActiveSync connection remains. Can you tell me why it happens

Any help to help me solve these problems is much appreciated.
Thanks,
Archana



Answer this question

Socket connection in .net CF

  • Aerouk

    Hi Sonali,

    If you downloaded the code from MSDN (Asynchronous server/ client), you need to alter the client code.

    In the client program, the endPoint created will not be actually pointing to your server. Once you change it, the program will work.

    Hope that helps.

  • rdeal3

    Daffodils wrote:

    I downloaded the sample synchronous server and client programs from the msdn. The programs work fine when both the server and client are running in the PC. However, when I run the client proggram in the pocket pc, it throws a socket exception. Can you tell why it happens.

    Also, my device gets connected to the internet using Wi-fi connection. But the moment I use a USB cable to connect it to my PC, to deploy my program and test it, the wi-fi connections get disabled. Only the ActiveSync connection remains. Can you tell me why it happens

    1. SocketException is thrown for several reasons, Make sure you are giving right IP Address and Port of your PC on which you are connecting the Client. And See SocketError code what does it say.
    2. Yes ActiveSync Disconnects any other Wifi or GPRS connection when Device is put on Cradle, I think this is normal behavior of it, I have never seen any option which forbids it to do so.

    Best Regards,



  • Hauri

    Hey all!

    I think I know what the problem is, cause I have the some and I have not been able to go around it. This is what I think happens:

    Using Sockets while the PDA is in the cradle doesnt work very well because whenever you try to do a connect ActiveSync (or whatever) ALWAYS replies with a OK - that you are connected - no matter what. So, if you have code to check if you are connected or not that code will ALWAYS return true.

    When you then try to send data you will probably get an IOException and then a SocketException because you are probably not connected at all.

    Now, this might not be a big problem if you know for sure that you have a connection. If you indeed are connected then it will work but if you're not it will generate exceptions. That is my 2 cents about this issue...

    Regards


  • RhodeHummel

    even I am facing the same problem.

    Are there any settings in Activesync
    I am using desktop's ip address and a specific port to connect.

    Pockepc is connected via Activesync 4.1 though USB.


    sock.BeginConnect method in client code does not trigger the listner socket in server program.

    please help.


  • Socket connection in .net CF