WLAN communication

Discussion in 'Questions (Windows Mobile)' started by WolfgangGruia, Jul 17, 2008.

  1. WolfgangGruia

    WolfgangGruia Member Licensed User

    How do I manage a connection over WLAN from the device to a PC ?
     
  2. mamuen

    mamuen Member Licensed User

    Hi Wolfgang,

    you can handle it like a normal networkconnection. Use the network.dll !

    Greating Mamuen
     
  3. WolfgangGruia

    WolfgangGruia Member Licensed User

    I want to use the WLAN for communication. So I wrote 2 little programs:

    Clientside:

    Sub ButtonSend_Click

    stream.New1(client.GetStream,false)
    stream.WriteString(Chr(2) & "010101001" & Chr(3))

    End Sub


    Sub ButtonConnect_Click

    client.New1
    client.Connect(client.GetIP2("PPP_PEER"),50000) 'Use Activesync IP.
    Msgbox("Client connected.")

    End Sub


    Serverside:

    Sub App_Start

    server.New1(50000) 'Listens on port 50000 (all ip's available).
    server.Start ' Server Objekt for send (Server is always a Sender)
    client.New1 ' Client Object for receiving
    client.Value = server.Accept 'This line will block waiting for the other client to connect.
    Msgbox("Server connected.")
    stream.New1(client.GetStream,false) 'Creates a BinaryFile object using the GetStream method.

    Do While true
    If client.DataAvailable Then Msgbox(stream.ReadString)
    DoTasks
    Loop
    End Sub


    It works fine, but if I use:

    client.Connect(client.GetIP2("MSHEIMNETZ"),50000) ' use WLAN


    with 'MSHEIMNETZ' name of the WLAN-network instead of the Activesync IP 'PPP_PEER', I get error messages.

    What have I to do?


    Regards
     
  4. taximania

    taximania Well-Known Member Licensed User

    I'm struggling with WLAN too.
    AGraham's app used to work, but doesn't anymore :confused:

    The chit-chat app just hangs and refuses to run on my device(s).
     
  5. mamuen

    mamuen Member Licensed User

    Hi Wolfgang,

    In the funktion client.connect you have to use the server-IP not the client one. In the client-server-modell the server is allways listening not the client.
     
  6. WolfgangGruia

    WolfgangGruia Member Licensed User

    Dear Mamuen,

    what do I have to put into 'client.getIP2(?????)' ?

    Best regards
     
  7. mamuen

    mamuen Member Licensed User

    Hi WolfgangGruia,

    you have to put the server name into.

    client.Connect(client.GetIP2("servername"),50000)

    Client.getIP2() seem to generate a DNS-request. For the first test i think it is better to use his IP-Address:

    client.Connect ("192.168.1.100",50000)

    regards Mamuen
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    If you are connecting through ActiveSync you should use:
    Code:
    [FONT=Verdana][COLOR=#010101]client.Connect (client.GetIP2 ("PPP_PEER"), 50000)
    [/COLOR][/
    FONT]

    Otherwise you could find the server's name with Server.HostName (from the server).

     
  9. WolfgangGruia

    WolfgangGruia Member Licensed User

    Dear Erel,

    It still doesn't work.My code is:


    On the device:

    client.New1
    server.New1 (50000)
    client.Connect(client.GetIP2(server.hostname),50000) 'Use Activesync IP.
    Msgbox("Client connected.")
    stream.New1(client.GetStream,false)

    ...

    stream.WriteString(st)




    On the PC:

    server.New1(50000) 'Listens on port 50000 (all ip's available).
    server.Start ' Server Objekt zum Senden (Server ist immer Sender)
    client.New1 ' Also Client Objekt for the receive part
    Do While server.Pending = false
    DoEvents
    Loop
    client.Value = server.Accept
    Msgbox("Server connected.")
    stream.New1(client.GetStream,false) 'Creates a BinaryFile object using the GetStream method.

    Do While true
    If client.DataAvailable Then Msgbox(stream.ReadString)
    DoTasks
    DoEvents
    Loop
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Server.HostName can only be used on the server side.
    On the pc check its value with: Msgbox(Server.HostName)
    Afterward enter this name on the client.
     
  11. taximania

    taximania Well-Known Member Licensed User


    WLAN = Wireless Local Area Network, am I right ?

    I can connect either of my PDA's when connected via ActiveSync
    to my laptop, which has built in Wifi,
    but it won't connect if I unplug my ActiveSync cable :confused:

    I have a Mio168 clone WM2003SE with a WLAN SD card, and an
    O2 XDA with built in WLAN.
    They see each other, but I can't get them to connect over Wifi :sign0148:
     
  12. mamuen

    mamuen Member Licensed User

    Hi,

    if you want to connect two Wlan-devices direct (Ad-Hoc Network), they must have:

    IP-adresses from the same Subnet for example:
    1. Device 192.168.1.1 (Laptop)
    2. Device 192.168.1.2 (PDA)
    Both must have the same Subnetmask
    255.255.255.0
    Now they are in the same logical Network and can see each other, not more.

    The next step is the WLAN-Configuration.
    Both must have the same Wlan-encryption (WEP /WPA) and the same "pre shared Key" -> Password. For the first test disable Wlan-encryption. Check on both Devices if the Wlanmode is Ad-Hoc and they work on the same Channel (1-13).

    Now you can test the connection, type on the Laptop (Dos Promt)
    c:\ ping 192.168.1.2 and see what happens.

    much luck Mamuen
     
    Last edited: Jul 22, 2008
  13. WolfgangGruia

    WolfgangGruia Member Licensed User

    I get an error message(An error occured on sub _app_start) with this
    following code:


    client.New1
    client.Connect(client.GetIP2("wolfgang-213efe"),50000) ' use WLAN
    stream.New1(client.GetStream,false)

    The version below (with ActiveSybnc IP) works.

    client.New1
    client.Connect(client.GetIP2("PPP_PEER"),50000) 'Use Activesync IP.
    stream.New1(client.GetStream,false)

    Does anyone know why?
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    What does the error message say?
    Please add a msgbox and check the value of client.GetIP2("...").
     
  15. WolfgangGruia

    WolfgangGruia Member Licensed User

    Dear Erel,

    I have put a msgbox() into it:

    client.New1
    st = client.GetIP2("wolfgang-213efe")
    Msgbox(st)
    client.Connect(client.GetIP2("wolfgang-213efe"),50000) ' use WLAN

    But the error message is the same: An error occurred on sub _app_start!
    And there is no output of the inserted Msgbox(st)

    Best regards

    Wolfgang
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Try to run the source code from the device IDE.
    It will show you the line that raises the error (probably the GetIP2 line).
    The error message should include some description.
     
  17. mamuen

    mamuen Member Licensed User

    Hi Erel,

    if i run this Prog. on my Laptop:

    Sub App_Start
    client.New1
    client.Connect(client.GetIP2("Servername"),50000)
    Msgbox("Client connected.")
    stream.New1(client.GetStream,false)
    Msgbox(stream.ReadString)
    client.Close
    End Sub

    client.GetIP2("Servername")
    returns the IP of the Server, but only if i have an DNS-Server in my network to resolve the name into an IP-Address! Otherwise i get an error. The fewest people have a DNS-Server running in here homenetwork. So i think its better to use a static IP-Adress (e.g. 192.168.1.1) for the server and use :
    client.Connect("192.168.1.1",50000)

    regards Mamuen
     
    Last edited: Jul 24, 2008
  18. Erel

    Erel Administrator Staff Member Licensed User

    I agree.
    @Wolfgang, on the pc run :cmd.exe and ipconfig.exe. It will show you the computer's IP address.
    Use the IP address directly.
     
  19. WolfgangGruia

    WolfgangGruia Member Licensed User

    Dear Erel

    Thanks again for the help.

    I tried using the IP address directly in client.connect() instead
    of using the PC-hostname.But I got the same error again.

    I put my source program into the ASUS device and I run the program within
    the Basic4ppc device. I got the following error:

    'Error loading program'

    Best Regards

    Wolfgang

    PS. Thanks also to Mamuen
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure you've copied all required images and libraries to the device?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice