我能传递一个文字,它就像一个魅力!
StreamSocketListener streamSocketListener = new StreamSocketListener();
streamSocketListener.ConnectionReceived += streamSocketListener_ConnectionReceived;
await streamSocketListener.BindEndpointAsync(hostName, port);
它显示了其他设备浏览器中的链接。
答案 0 :(得分:2)
伪代码:
IStorageFile fileToSend = await KnownFolders.PicturesLibrary.GetFileAsync("foo.jpg");
BasicProperties basicProperties = await fileToSend.GetBasicPropertiesAsync();
IInputStream streamToSend = await fileToSend.OpenReadAsync();
string headers = "HTTP/1.1 OK 200\r\n" +
"Content-Length:" + basicProperties.Size + "\r\n" +
"Content-Type: " + fileToSend.ContentType + "\r\n" +
"Connection: Keep-Alive\r\n\r\n";
writer.WriteString(stringToSend);
await writer.StoreAsync();
writer.DetachStream();
await RandomAccessStream.CopyAndCloseAsync(streamToSend, socket.OutputStream);