Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

WLAN communication

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2008, 04:30 PM
Junior Member
 
Join Date: Jul 2008
Posts: 15
Default WLAN communication

How do I manage a connection over WLAN from the device to a PC ?
Reply With Quote
  #2 (permalink)  
Old 07-17-2008, 06:07 PM
Knows the basics
 
Join Date: Mar 2008
Location: germany, Heidelberg
Posts: 90
Default

Hi Wolfgang,

Quote:
Originally Posted by WolfgangGruia View Post
How do I manage a connection over WLAN from the device to a PC ?
you can handle it like a normal networkconnection. Use the network.dll !

Greating Mamuen
Reply With Quote
  #3 (permalink)  
Old 07-20-2008, 07:21 AM
Junior Member
 
Join Date: Jul 2008
Posts: 15
Default

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
Reply With Quote
  #4 (permalink)  
Old 07-20-2008, 09:16 AM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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

The chit-chat app just hangs and refuses to run on my device(s).
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #5 (permalink)  
Old 07-20-2008, 10:32 AM
Knows the basics
 
Join Date: Mar 2008
Location: germany, Heidelberg
Posts: 90
Default

Hi Wolfgang,

Quote:
Originally Posted by WolfgangGruia View Post

...... 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.
Reply With Quote
  #6 (permalink)  
Old 07-20-2008, 03:05 PM
Junior Member
 
Join Date: Jul 2008
Posts: 15
Default

Dear Mamuen,

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

Best regards
Reply With Quote
  #7 (permalink)  
Old 07-20-2008, 06:45 PM
Knows the basics
 
Join Date: Mar 2008
Location: germany, Heidelberg
Posts: 90
Default

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
Reply With Quote
  #8 (permalink)  
Old 07-20-2008, 07:39 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

If you are connecting through ActiveSync you should use:
Code:
<font face="Verdana"><font color="#010101">client.Connect (client.GetIP2 ("PPP_PEER"), 50000)
</font></font>

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

Reply With Quote
  #9 (permalink)  
Old 07-21-2008, 06:17 PM
Junior Member
 
Join Date: Jul 2008
Posts: 15
Default

Dear Erel,

It still doesn't work.My code is:


On the device:

client.New1
server.New1 (50000)
client.Connect(client.GetIP2(server.hostname),5000 0) '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
Reply With Quote
  #10 (permalink)  
Old 07-21-2008, 07:09 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial communication - problems with reading token Questions (Windows Mobile) 11 02-19-2009 01:51 PM
Interprocess communication with the Network library Erel Code Samples & Tips 0 08-19-2008 10:37 AM


All times are GMT. The time now is 10:06 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0