views:

55

answers:

1

I have to communicate with an iPhone. I have its IP Address and the port (obtained via Bonjour).

I need to send a header that is “0x50544833” (or similar, It’s an HEX number), then the size of the data (below) and then the data itself.

The data is just a string that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist SYSTEM "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<plist version="1.0">
    <dict>
        <key>clientName</key>
        <string>XXX</string>
        <key>clientService</key>
        <string>0be397e7-21f4-4d3c-89d0-cdf179a7e14d</string>
        <key>registerCode</key>
        <string>0000</string>
    </dict>
</plist>

The requirement also says that I must send the data in little endian format (which I think is the default for Intel anyway).

So it would be: hex_number + size of data + string_with_the_above_xml.

I need to send that to the iPhone and read the response.

What would be, according to your experience, the best way to send this data (and read the response)?

update: I didn’t write the iPhone software. It uses Tcp/Ip. The port depends upon the Operating System, but I’ve seen it ranging from 57xxx to 60xxxx, not always. The Mac version of this software uses Tcp/Ip. I have no access to its source code, but I am in contact with its developer, who explained me the format of the data I need to send and then, once the Bonjour service was resolved, “open a socket and …”

+1  A: 

Yes, you can use TcpClient for this scenario. It will work perfectly in this case.

feroze