Given the no direct tcp / socket limitation in Windows Phone 7 I was wondering what is the way that has the least performance overhead and/or can send it in the most compact way.
I think I can send the data as a file using HTTP (probably with an HTTPWebRequest) and encode it as Base64, but this would increase the transfer size significantly. I could use WCF but the performance overhead is going to be large as well.
Is there a way to send plain binary data without encoding it, or some faster way to do so?
Given the no direct tcp / socket limitation in Windows Phone 7 I was
Share
If you want to send binary data, then certainly some people have been using raw sockets – see
Connect to attached pc from WP7 by opening a socket to localhost
However, unless you want to write your own socket server, then HTTP is very convenient. As Matt says, you can include binary content in your HTTP requests. To do this, you can use the headers:
To actually set these headers, you may need to send this as a multipart message… see questions like Upload files with HTTPWebrequest (multipart/form-data)
There’s some excellent sample code on AppHub forums – http://forums.create.msdn.com/forums/p/63646/390044.aspx – shows how to upload a binary photo to Facebook.
Unless your data is very large, then it may be easier to take the 4/3 hit of Base64 encoding 🙂 (and there are other slightly more efficient encoding types too like Ascii85 – http://en.wikipedia.org/wiki/Ascii85)