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

  • Question

  • 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

    Tuesday, July 12, 2005 3:17 PM

Answers

  • 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!  
    Thursday, July 14, 2005 2:05 PM