Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lewis Benge. // using Windows.Networking; // using Windows.Networking.Sockets; var socket = new StreamSocket(); var hostName = new HostName("example.com");

Similar presentations


Presentation on theme: "Lewis Benge. // using Windows.Networking; // using Windows.Networking.Sockets; var socket = new StreamSocket(); var hostName = new HostName("example.com");"— Presentation transcript:

1 Lewis Benge

2

3

4

5

6

7

8

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();

13

14

15

16

17

18

19

20

21

22

23 DEMO: Mashing up devices Bluetooth, WiFi, Sockets

24

25

26

27

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/

29


Download ppt "Lewis Benge. // using Windows.Networking; // using Windows.Networking.Sockets; var socket = new StreamSocket(); var hostName = new HostName("example.com");"

Similar presentations


Ads by Google