Sending XML to a Pocket PC by Sockets

G

Guest

Hallo,

I can send Socket information from the Pocket PC to a PC but not from the PC to the Pocket PC. My problem is that I have a Pocket PC that does not have a network adapter. So I use only USB and Active synch to connect to my Work network. I am able to setup both an emulator and a physical Pocket PC in a way that I can browse the internet or send IP Packets with Sockets. BUT I am not able to ping the pocket PC and consequently I cannot send Socket information to the Pocket PC.

Since my target customer does not have any webservers I cannot sidestep this issue with Webservices :(

Any suggestions ideas?
thanks...

Nigel...
 
G

Guest

Just in case anyone wants to know the answer..

Apparently this is no problem if the Pocket PC has a network card. However if it has no network card and you are using Active Synch the Pocket PC takes the same IP as the PC and is able to send but not listen..

If there is anyone out there programming for home users I would be interested to here how you send data from the PC to the Pocket PC. Personally I am going to look at Pocket Access or maybe some API function to the Active Syn

have fun..

Nigel...
 
R

Richard L Rosenheim

As long as the Pocket PC initiates the conversation, it should be able to
receive the XML file.

Richard Rosenheim


Nigel Findlater said:
Hallo,

I can send Socket information from the Pocket PC to a PC but not from the
PC to the Pocket PC. My problem is that I have a Pocket PC that does not
have a network adapter. So I use only USB and Active synch to connect to my
Work network. I am able to setup both an emulator and a physical Pocket PC
in a way that I can browse the internet or send IP Packets with Sockets. BUT
I am not able to ping the pocket PC and consequently I cannot send Socket
information to the Pocket PC.
 
G

Guest

Hallo Richard

Have you got an example where this is done

I think it should be possible because otherwize the internet browser would not work. However in my special case of a PocketPC on a SUB cradel I cannot see anyway to do this with TCPListner because the pocket pc actively refuses the connection

I would really appriciate a snippet of code or a hint where I can find a solution. Any suggestions

Nigel...
 
R

Richard L Rosenheim

How about "The Definitive Guide to the .Net Compact Framework" by Larry Roof
with Dan Fergus?

Chapter 15 is about mobile networking. Starting on page 593, is "Developing
a TCP Server" The book goes through the following steps, complete with
code:

1. Opening a port for listening
2. Start listening
3. Checking if there are any pending requests
4. Accepting client requests
5. Receiving data from the client
6. Processing the data packet
7. Building a response packet
8. Returning the packet to the client.

The chapter also covers developing a TCP client.

Hope this helps. The disclaimer is that I haven't actually utilized this
code, but I would assume it works.

Richard Rosenheim


Nigel Findlater said:
Hallo Richard,

Have you got an example where this is done?

I think it should be possible because otherwize the internet browser would
not work. However in my special case of a PocketPC on a SUB cradel I cannot
see anyway to do this with TCPListner because the pocket pc actively refuses
the connection.
 
G

Guest

Here is the solution

Pocket P
Dim tcpClient As New System.Net.Sockets.TcpClien
Dim LocalIp As New System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.1.123"), 8000
tcpClient.Connect(LocalIp
Dim networkStream As NetworkStream = tcpClient.GetStream(
If networkStream.CanWrite And networkStream.CanRead The
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Hallo From PocketPC"
networkStream.Write(sendBytes, 0, sendBytes.Length

Dim bytes(tcpClient.ReceiveBufferSize) As Byt
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)
Dim returndata As String = Encoding.ASCII.GetString(bytes, 0, bytes.Length
MessageBox.Show(("Host returned: " + returndata)
Els
If Not networkStream.CanRead The
MessageBox.Show("cannot not write data to this stream"
tcpClient.Close(
Els
If Not networkStream.CanWrite The
MessageBox.Show("cannot read data from this stream"
tcpClient.Close(
End I
End I
End I

P
Dim LocalIp As New System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.1.123"), 8000
Dim tcpListener As New TcpListener(LocalIp
tcpListener.Start(

Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient(
Dim networkStream As NetworkStream = tcpClient.GetStream(

Dim XMLBytes(tcpClient.ReceiveBufferSize) As Byt
networkStream.Read(XMLBytes, 0, CInt(tcpClient.ReceiveBufferSize)
Dim XMLStr As String = System.Text.Encoding.ASCII.GetString(XMLBytes

Dim responseString As String = "Hallo From Server
Dim sendBytes As [Byte]() = System.Text.Encoding.ASCII.GetBytes(responseString
networkStream.Write(sendBytes, 0, sendBytes.Length
tcpClient.Close(
tcpListener.Stop(

There is a good article about the details of this at
http://www.eggheadcafe.com/articles/20020323.as

have fun everyone..

Nigel..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top