0

I have been trying to figuring out if it is possible to send files between a wp8 device and a windows rt (Surface). Some people seem to write that this is possible but they never write how to do this.

So what I want to do is 1. record a video with my app on the wp8 device and save it to the isolated storage (this is where Im at, at the moment) 2. Send the video (approx 20min recording time) to my windows rt device 3. Play the video on the rt device. Step 1 & 3 are simple but step 2 is driving me crazy. I have been thinking about using Bluetooth but as the speed is just around 700kbit/s it will take forever to transfer it. Usb is a no go as it is in the isolated storage. Skydrive needs 3g. So what I am thinking is to start internet sharing on my wp8 device and then connect my windows rt device to it and when its done use wifi to send the video from wp8 to win rt.

Is there any way this could work or is this impossible?

user1842278
  • 1,039
  • 1
  • 12
  • 25

2 Answers2

2

If your devices are in the same Wi-Fi network, you can use it to send files. Glossing over the details, this could be achieved in two steps:

  1. Make devices discover each other in the network (they should know each other's ip addresses).
  2. Implement file sending over a tcp socket. The simplest approach is to split the file into chunks of some arbitrary, but small size, and send those chunks one after another.

Of course, it's a high-level description, so if you need some further help in topics mentioned above, feel free to ask.

EDIT: This url says that there's a possibility to listen to incoming network connections, because related class is available for Windows Store apps and for Windows Phone 8. You can use it as a starting point.

EDIT 1: I've quickly put up an example for you, to prove it works. Just tested it on my Lumia 920.

Windows.Networking.Sockets.StreamSocketListener listener = new Windows.Networking.Sockets.StreamSocketListener();                    
listener.ConnectionReceived += async (_, args) =>
{
    var w = new Windows.Storage.Streams.DataWriter(args.Socket.OutputStream);
    w.WriteInt32(42);
    await w.StoreAsync();
};
await listener.BindEndpointAsync(new Windows.Networking.HostName("127.0.0.1"), "55555");
var clientSocket = new Windows.Networking.Sockets.StreamSocket();
await clientSocket.ConnectAsync(new Windows.Networking.HostName("127.0.0.1"), "55555");

var r = new Windows.Storage.Streams.DataReader(clientSocket.InputStream);
await r.LoadAsync(4);
var res = r.ReadInt32();
clientSocket.Dispose();
System.Windows.MessageBox.Show(res.ToString(), "The Ultimate Question of Life, the Universe, and Everything", System.Windows.MessageBoxButton.OK);
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
  • That sounds highly interesting, I was searching for some way to start with this but I only found how to do this with an server involved and neither wp8 or winrt can be a server. So if you could Point me to some tutorials or just some functions to use it would be great! – user1842278 Apr 18 '13 at 13:51
  • Was to slow to edit... Now I open the isolated filestream and read 512 bytes at the time and then send them with the datawriter. On the receiver side I use the Partial configuration and then I read the unread by using LoadAsync(UnconsumedBufferLength). Then I have to loop through the LoadAsync until I have 0 bytes loaded right? – user1842278 Apr 18 '13 at 21:15
  • Well, not exactly. You cannot have 0 bytes loaded, because there will be no load at all if there's nothing in the socket's InputStream. What you really need to do is to implement some kind of network protocol on top of TCP for file sending. For example, assuming that your files are less than 2 Gb, and one 4-byte integer is enough to hold the length of the file, you can first send one integer with the length of the file, and then file itself. On recipient side, you'll read first integer from the socket, determine file's length and then read that amount of bytes from the socket. – Haspemulator Apr 19 '13 at 07:47
0

Is this something you are trying to do in code? What is your average file size - are we talking low-res 320x480 or HD-quality 720p+ video...? What are your limitations? (Time, Connectivity, etc)

You could set up Dropbox to do the transfer. The free version is limited in space (more if you share), but if you moved the files into and out of Dropbox as necessary then you'd at least be able to set it and forget about it. This would still require a network connection, so if you need to do this on the go it may not be a good answer.

If this is something you need to do while on vacation at Disney World or camping or something like that it may not be a viable option.

alexpwalsh
  • 39
  • 10