establishing a TCP connection in pocket pc emulator

jonathanSokanovic

New member
Joined
Jul 12, 2005
Messages
1
Programming Experience
3-5
Hi I am trying to create a server application that, once started, a Pocket PC application can connect to to retrive data. I cant even get a connection established with the Pocket PC device. I am constantly getting the socket exception saying the host activly refused the connection.

I am using the loop back adapter and have bound the NE2000 card to it. Host only networking is also enabled. I have also removed the firewall from the loopback adapter.

My server code is as follows


Imports
System.Net

Imports System.Net.Sockets

Imports System.IO

Imports System.Text


Dim
Transmitter As TcpListener

Dim Connection As TcpClient

Dim ListenOn As New IPEndPoint(IPAddress.Parse("127.0.0.1"), 5000)

Dim Response As String = "server response"

Transmitter = New TcpListener(ListenOn)

Transmitter.Start()

Connection = Transmitter.AcceptTcpClient()

Dim ByteConversionArray() As Byte

ByteConversionArray = Encoding.ASCII.GetBytes(Response)

Connection.GetStream()

Connection.GetStream.Write(ByteConversionArray, 0, ByteConversionArray.Length)

Connection.Close()



The code on the device is as follows


Imports
System.Net

Imports System.Net.Sockets

Imports System.IO

Imports System.Text

Dim Client As New TcpClient

Dim response As String

Dim remoteEP As New IPEndPoint(IPAddress.Parse("127.0.0.1"), 5000)

'Try

Client.Connect(remoteEP) ' the code fails here

'Catch sexp As SocketException

'End Try

Dim stream = Client.GetStream()

Dim InputBuffer(128) As Byte

Client.GetStream.Read(InputBuffer, 0, InputBuffer.Length)

response = Encoding.ASCII.GetString(InputBuffer, 0, InputBuffer.Length)

Client.Close()

TxtMessage.Text = response


If any one has any ideas I would appreciate it
Thanks
Jon
 
Hi there, the Pocket PC will not take 127.0.0.1 as the IP for the Desktop PC, I f you try 192.168.55.100 it may work, if not I will give you my client-server application, which have already worked
 
it is long time I haven't been working on mobile application already, but I will have a look at the past stuff to show you, just keep cheking this thread
 
try this as ur client code


Dim oRemoteAddress As Net.IPAddress
Dim oIPEndPoint As Net.IPEndPoint
Dim m_oNetStream As NetworkStream
Dim m_oBinReader As BinaryReader
Dim m_oBinWriter As BinaryWriter


oRemoteAddress = Net.IPAddress.Parse("192.168.1.2")
oIPEndPoint = New Net.IPEndPoint(oRemoteAddress, 9999)


m_oSocket = New Socket(oIPEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)

m_oSocket.Connect(oIPEndPoint)

m_oNetStream = New NetworkStream(m_oSocket)
m_oBinReader = New BinaryReader(m_oNetStream)
m_oBinWriter = New BinaryWriter(m_oNetStream)
m_oBinWriter.Write("Connecting")

Loopback does not work in pocket pc. The server and clent communicates over the port 9999. Use the ip that u get it using ipconfig on ur cmd prompt.

I tried using TcpClient class but it was not successful.
 
Back
Top