M
Mobileboy36
Hi All,
If 2 network connections are available (GPRS and WLAN OR GPRS and LAN) the
pocket PC has to choose the 'cheapest' one, so in this case WLAN or LAN and
not GPRS.
So, my idea was to write an application called GPRS monitor, to control the
GPRS connection
Using functionality of OPENNETCF.NET 2.0 I 'm able to setup a connection
using VB.NET code.
But I'm encountering problems disconnecting the GPRS...My DisconnectGPRS
function (using OpenNETCF.Net.ConnectionManager) does not work...
On http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=7423 I found someone
with the same problem.
Is there yet a solution for this?
Am I doing something wrong?
Or does someone know a (third party) tool for pocket pc and Windows Ce to
give connections a priority value:
1. LAN
2. WLAN
3. GPRS
In addition you can find the code...
I hope to find a solution.
Any help would be greatly appreciated
best regards,
Mobile boy
Public Class ConnectionManager
Private _ConnectionManager As OpenNETCF.Net.ConnectionManager
Private _PingList As List(Of String)
Private _PingTimeOut As Integer
Private _PingInterval As Integer
Public Sub New(ByVal PingList As List(Of String), ByVal PingTimeOut As
Integer)
_ConnectionManager = New OpenNETCF.Net.ConnectionManager()
_PingList = PingList
_PingTimeOut = PingTimeOut
End Sub
Public Sub ConnectGPRS()
Dim MyDestinationInfoCollection As
OpenNETCF.Net.DestinationInfoCollection
MyDestinationInfoCollection = _ConnectionManager.EnumDestinations()
If Not Pingable() Then
Try
For Each Di As OpenNETCF.Net.DestinationInfo In
MyDestinationInfoCollection
Dim str As String = Di.Description
If (Di.Description.ToLower.StartsWith("the internet"))
Then
' het zou kunnen dat the internet op andere
operating systemen
' internet wordt of nog iets anders
_ConnectionManager.Connect(Di.Guid, False,
OpenNETCF.Net.ConnectionMode.Synchronous)
End If
Next
Catch ex As Exception
End Try
End If
End Sub
Private Function Pingable() As Boolean
Dim MyPingobject As New OpenNETCF.Net.NetworkInformation.Ping
Dim MyPingReply As OpenNETCF.Net.NetworkInformation.PingReply
Dim En As System.Collections.Generic.List(Of String).Enumerator
Dim PingSucceeded As Boolean = False
Try
En = _PingList.GetEnumerator
While En.MoveNext And Not PingSucceeded
If En.Current <> "" Then
MyPingReply = MyPingobject.Send(En.Current,
_PingTimeOut)
PingSucceeded = (MyPingReply.Status =
OpenNETCF.Net.NetworkInformation.IPStatus.Success)
End If
End While
Catch ex As Exception
End Try
MsgBox("pingable: " & PingSucceeded)
Return PingSucceeded
End Function
Public Sub DisconnectGPRS()
' http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=7423
' Does not always work
Dim MyHttpWebRequest As System.Net.HttpWebRequest
Dim HttpResponse As System.Net.HttpWebResponse
Dim MyStreamReader As System.IO.StreamReader
Try
'MsgBox("Begin DisconnectGPRS")
'MyHttpWebRequest =
System.Net.WebRequest.Create("http://www.google.com")
'HttpResponse = CType(MyHttpWebRequest.GetResponse,
System.Net.HttpWebResponse)
'MyStreamReader = New
System.IO.StreamReader(HttpResponse.GetResponseStream())
'MyStreamReader.Close()
MsgBox("Before DisconnectGPRS")
_ConnectionManager.Disconnect()
MsgBox("After DisconnectGPRS")
Catch ex As Exception
End Try
End Sub
If 2 network connections are available (GPRS and WLAN OR GPRS and LAN) the
pocket PC has to choose the 'cheapest' one, so in this case WLAN or LAN and
not GPRS.
So, my idea was to write an application called GPRS monitor, to control the
GPRS connection
Using functionality of OPENNETCF.NET 2.0 I 'm able to setup a connection
using VB.NET code.
But I'm encountering problems disconnecting the GPRS...My DisconnectGPRS
function (using OpenNETCF.Net.ConnectionManager) does not work...
On http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=7423 I found someone
with the same problem.
Is there yet a solution for this?
Am I doing something wrong?
Or does someone know a (third party) tool for pocket pc and Windows Ce to
give connections a priority value:
1. LAN
2. WLAN
3. GPRS
In addition you can find the code...
I hope to find a solution.
Any help would be greatly appreciated
best regards,
Mobile boy
Public Class ConnectionManager
Private _ConnectionManager As OpenNETCF.Net.ConnectionManager
Private _PingList As List(Of String)
Private _PingTimeOut As Integer
Private _PingInterval As Integer
Public Sub New(ByVal PingList As List(Of String), ByVal PingTimeOut As
Integer)
_ConnectionManager = New OpenNETCF.Net.ConnectionManager()
_PingList = PingList
_PingTimeOut = PingTimeOut
End Sub
Public Sub ConnectGPRS()
Dim MyDestinationInfoCollection As
OpenNETCF.Net.DestinationInfoCollection
MyDestinationInfoCollection = _ConnectionManager.EnumDestinations()
If Not Pingable() Then
Try
For Each Di As OpenNETCF.Net.DestinationInfo In
MyDestinationInfoCollection
Dim str As String = Di.Description
If (Di.Description.ToLower.StartsWith("the internet"))
Then
' het zou kunnen dat the internet op andere
operating systemen
' internet wordt of nog iets anders

_ConnectionManager.Connect(Di.Guid, False,
OpenNETCF.Net.ConnectionMode.Synchronous)
End If
Next
Catch ex As Exception
End Try
End If
End Sub
Private Function Pingable() As Boolean
Dim MyPingobject As New OpenNETCF.Net.NetworkInformation.Ping
Dim MyPingReply As OpenNETCF.Net.NetworkInformation.PingReply
Dim En As System.Collections.Generic.List(Of String).Enumerator
Dim PingSucceeded As Boolean = False
Try
En = _PingList.GetEnumerator
While En.MoveNext And Not PingSucceeded
If En.Current <> "" Then
MyPingReply = MyPingobject.Send(En.Current,
_PingTimeOut)
PingSucceeded = (MyPingReply.Status =
OpenNETCF.Net.NetworkInformation.IPStatus.Success)
End If
End While
Catch ex As Exception
End Try
MsgBox("pingable: " & PingSucceeded)
Return PingSucceeded
End Function
Public Sub DisconnectGPRS()
' http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=7423
' Does not always work
Dim MyHttpWebRequest As System.Net.HttpWebRequest
Dim HttpResponse As System.Net.HttpWebResponse
Dim MyStreamReader As System.IO.StreamReader
Try
'MsgBox("Begin DisconnectGPRS")
'MyHttpWebRequest =
System.Net.WebRequest.Create("http://www.google.com")
'HttpResponse = CType(MyHttpWebRequest.GetResponse,
System.Net.HttpWebResponse)
'MyStreamReader = New
System.IO.StreamReader(HttpResponse.GetResponseStream())
'MyStreamReader.Close()
MsgBox("Before DisconnectGPRS")
_ConnectionManager.Disconnect()
MsgBox("After DisconnectGPRS")
Catch ex As Exception
End Try
End Sub