establishing a TCP connection from an emulated device (Pocket PC)

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 TransmitterAs TcpListener

Dim ConnectionAs TcpClient

Dim ListenOnAsNew IPEndPoint(IPAddress.Parse("127.0.0.1"), 5000)

Dim ResponseAsString ="server response"

Transmitter =New TcpListener(ListenOn)

Transmitter.Start()

Connection = Transmitter.AcceptTcpClient()

Dim ByteConversionArray()AsByte

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 ClientAsNew TcpClient

Dim responseAsString

Dim remoteEPAsNew 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)AsByte

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

[3734 byte] By [JonathanSokanovic] at [2008-2-6]
# 1
Hi all
Unfortunatly this code is correct and my own stupididty cause this problem.
THe IP address is the one that used for loop back but my loopback adapter is
configured to another IP address. I used the other IP adress and it works correctly.
Thanks to anybody who took the time to read this post!
JonathanSokanovic at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...

.NET Development

Site Classified