WLAN communication

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
 

mamuen

Member
Licensed User
Hi Wolfgang,

...... 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?

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.
 

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
 

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
 

taximania

Well-Known Member
Licensed User
Longtime User
Erel said:
If you are connecting through ActiveSync


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:
 

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:

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?
 

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
 

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:

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
 
Top