G
Guest
Hi,
I am new to socket connection on CF2.0
I am developing an application that runs on PocketPC 2003, using sockets it
connects to a desktop PC.
However everytime I start a connection, it takes about 10-15 seconds to get
connected before i can send data out......this is a long wait.
But this problem only happens if it is run for the first time, or if u leave
it disconnected for a period of time and re-connect again.
Here is my connection code:
' Resolve the name to an IP Address
Dim Addr As IPAddress = Dns.GetHostEntry(DNSname).AddressList(0)
If Not Addr Is Nothing Then
' Create an IP Endpoint
Dim EP As New IPEndPoint(Addr, CInt(DNSport))
' Create a new socket
clientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
' Connect
clientSocket.BeginConnect(EP, AddressOf ConnectCallback, Nothing)
Dim nowSec As Double = Microsoft.VisualBasic.DateAndTime.Timer
' wait for connection
Do While clientSocket.Connected = False
' Wait to be connected otherwise timeout
If Microsoft.VisualBasic.DateAndTime.Timer - nowSec > 20 Then
Exit sub
End If
Loop
End If
Any help please?
Many thanks in advance!
I am new to socket connection on CF2.0
I am developing an application that runs on PocketPC 2003, using sockets it
connects to a desktop PC.
However everytime I start a connection, it takes about 10-15 seconds to get
connected before i can send data out......this is a long wait.
But this problem only happens if it is run for the first time, or if u leave
it disconnected for a period of time and re-connect again.
Here is my connection code:
' Resolve the name to an IP Address
Dim Addr As IPAddress = Dns.GetHostEntry(DNSname).AddressList(0)
If Not Addr Is Nothing Then
' Create an IP Endpoint
Dim EP As New IPEndPoint(Addr, CInt(DNSport))
' Create a new socket
clientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
' Connect
clientSocket.BeginConnect(EP, AddressOf ConnectCallback, Nothing)
Dim nowSec As Double = Microsoft.VisualBasic.DateAndTime.Timer
' wait for connection
Do While clientSocket.Connected = False
' Wait to be connected otherwise timeout
If Microsoft.VisualBasic.DateAndTime.Timer - nowSec > 20 Then
Exit sub
End If
Loop
End If
Any help please?
Many thanks in advance!