Download presentation
Presentation is loading. Please wait.
Published byBeverly Smith Modified over 9 years ago
1
Lewis Benge
9
// using Windows.Networking; // using Windows.Networking.Sockets; var socket = new StreamSocket(); var hostName = new HostName("example.com"); string serviceName = "4554"; // Connect using regular TCP (no security). await socket.ConnectAsync(hostName, serviceName, SocketProtectionLevel.PlainSocket); // OPTIONAL: Enable SSL for security. await socket.ConnectAsync(hostName, serviceName, SocketProtectionLevel.Ssl);
10
// using Windows.Storage.Streams; var writer = new DataWriter(socket.OutputStream); // There’s Write*() APIs for a large number of types. writer.WriteInt32(42); await writer.StoreAsync(); // OPTIONAL: Set endian-ness (defaults to LittleEndian). writer.ByteOrder = ByteOrder.BigEndian;
11
// using Windows.Storage.Streams; var reader = new DataReader(socket.InputStream); // Read in exactly 4 bytes of data. await reader.LoadAsync(4); // There’s Read*() APIs for a large number of types. int number = reader.ReadInt32(); // Read in as many bytes as are available, up to 64K. reader.InputStreamOptions = InputStreamOptions.Partial; await reader.LoadAsync(64 * 1024);
12
// OPTIONAL: Close the socket. socket.Close();
23
DEMO: Mashing up devices Bluetooth, WiFi, Sockets
28
http://msdn.microsoft.com/en-au/ http://www.microsoftvirtualacademy.com/ http://channel9.msdn.com/Events/TechEd/Australia/2013 http://technet.microsoft.com/en-au/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.