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