<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Nikola Metulev</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/metulev/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/metulev/feed.xml</link>
    <description>Windows 8 Developer Evangelist</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:41:28 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Playing Youtube video in a Windows 8 Application</title>
      <link>https://docs.microsoft.com/archive/blogs/metulev/playing-youtube-video-in-a-windows-8-application</link>
      <pubDate>Tue, 27 Nov 2012 16:57:45 GMT</pubDate>
      <dc:creator><![CDATA[Nikola Metulev]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/metulev/2012/11/27/playing-youtube-video-in-a-windows-8-application/</guid>
      <description><![CDATA[Recently, I was working on a C# Windows 8 application that was required to play Youtube videos as...]]></description>
      <content:encoded><![CDATA[<p>Recently, I was working on a C# Windows 8 application that was required to play Youtube videos as one of the features. At first I wasn’t sure if there was a simple way to accomplish the task, but with a little research I found a very nice solution.</p>  <p>&#160;</p>  <p>First I created a very simple WebView in my *.xaml page:</p>  <div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">   <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">     <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">WebView</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;webView&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>&#160;</p>

<p>You’ll notice I haven’t specified any dimensions or any other attributes other than a name. I’ll use the name in my *.xaml.cs file to reference the WebView instance.</p>

<p>&#160;</p>

<p>Now in my *.xaml.cs file, I simply set the contents of the WebView to an iframe that contains the embedded youtube video. The size of the iframe will define the size of my WebView:</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> <span style="color: rgb(0, 0, 255);">string</span> html = <span style="color: rgb(0, 96, 128);">@&quot;&lt;iframe width=&quot;</span><span style="color: rgb(0, 96, 128);">&quot;800&quot;</span><span style="color: rgb(0, 96, 128);">&quot; height=&quot;</span><span style="color: rgb(0, 96, 128);">&quot;480&quot;</span><span style="color: rgb(0, 96, 128);">&quot; src=&quot;</span><span style="color: rgb(0, 96, 128);">&quot;https://www.youtube.com/embed/&quot;</span> + videoID + <span style="color: rgb(0, 96, 128);">@&quot;?rel=0&quot;</span><span style="color: rgb(0, 96, 128);">&quot; frameborder=&quot;</span><span style="color: rgb(0, 96, 128);">&quot;0&quot;</span><span style="color: rgb(0, 96, 128);">&quot; allowfullscreen&gt;&lt;/iframe&gt;&quot;</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum2" style="color: rgb(96, 96, 96);">   2:</span>&#160; </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum3" style="color: rgb(96, 96, 96);">   3:</span> <span style="color: rgb(0, 0, 255);">this</span>.webView.NavigateToString(html);</pre>
<!--CRLF--></div>
</div>

<p>&#160;</p>

<p><strong>videoID</strong> is a string containing the ID of the video you want. It’s the string that comes after the <strong>v=&#160; </strong>and before the <strong>&amp;</strong> in the video URL:</p>

<p>&#160;</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/1321.image_5C924D64.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/1321.image_5F00_5C924D64.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/4786.image_thumb_5F3B0915.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/4786.image_5F00_thumb_5F00_5F3B0915.png" width="567" height="157" /></a> </p>

<p>&#160;</p>

<p>The result is a youtube video embedded in your application with the familiar controls: </p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/7510.image_0A136D28.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/7510.image_5F00_0A136D28.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/0753.image_thumb_6E7171E2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/0753.image_5F00_thumb_5F00_6E7171E2.png" width="534" height="344" /></a> </p>

<p>&#160;</p>

<p>Enjoy.</p>]]></content:encoded>
    </item>
    <item>
      <title>WOWZAPP 2012 | Windows 8 Socket Networking Session Files</title>
      <link>https://docs.microsoft.com/archive/blogs/metulev/wowzapp-2012-windows-8-socket-networking-session-files</link>
      <pubDate>Sat, 10 Nov 2012 15:23:04 GMT</pubDate>
      <dc:creator><![CDATA[Nikola Metulev]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/metulev/2012/11/10/wowzapp-2012-windows-8-socket-networking-session-files/</guid>
      <description><![CDATA[Please find the presentation and finished project below.
SocketNetworkingPresentation.zip]]></description>
      <content:encoded><![CDATA[<p>Please find the presentation and finished project below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/36/74/94/SocketNetworkingPresentation.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-36-74-94/SocketNetworkingPresentation.zip">SocketNetworkingPresentation.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>WOWZAPP 2012 | Data Binding with XAML Controls Session Files</title>
      <link>https://docs.microsoft.com/archive/blogs/metulev/wowzapp-2012-data-binding-with-xaml-controls-session-files</link>
      <pubDate>Fri, 09 Nov 2012 16:44:00 GMT</pubDate>
      <dc:creator><![CDATA[Nikola Metulev]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/metulev/2012/11/09/wowzapp-2012-data-binding-with-xaml-controls-session-files/</guid>
      <description><![CDATA[To view the session, visit: https://new.livestream.com/wowzapp2012/bindingxaml
The slides, and...]]></description>
      <content:encoded><![CDATA[<p>To view the session, visit: <a href="https://new.livestream.com/wowzapp2012/bindingxaml">https://new.livestream.com/wowzapp2012/bindingxaml</a></p>
<p>The slides, and project files are attached below.</p>
<p>&nbsp;</p>
<p>Enjoy!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/36/73/87/DataBindingWithXAML.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-36-73-87/DataBindingWithXAML.zip">DataBindingWithXAML.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Networking in Windows 8 Apps - Using StreamSocket for TCP Communication</title>
      <link>https://docs.microsoft.com/archive/blogs/metulev/networking-in-windows-8-apps-using-streamsocket-for-tcp-communication</link>
      <pubDate>Mon, 22 Oct 2012 11:27:39 GMT</pubDate>
      <dc:creator><![CDATA[Nikola Metulev]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/metulev/2012/10/22/networking-in-windows-8-apps-using-streamsocket-for-tcp-communication/</guid>
      <description><![CDATA[My progress with Windows 8 App Development  If you read my first post, you know that I just recently...]]></description>
      <content:encoded><![CDATA[<h6>My progress with Windows 8 App Development</h6>  <p>If you read my first post, you know that I just recently started developing for Windows 8. Well, for the past week I have been building a simple <a href="https://en.wikipedia.org/wiki/Internet_Relay_Chat">IRC</a> client that is helping me get my feet wet with Windows 8 App development and the Windows 8 SDK. Building an IRC client is a perfect starting point on any platform, and specifically on Windows 8 since it allows me to learn and implement many of the new features in Windows 8 (such as the Search and Share Charm, Live Tiles, Toast Notifications and many more) and take advantage of the brand new APIs. I have been having a tremendous amount of fun developing the app and seeing the progress throughout the week, and I’m very excited to share my experience in a series of posts.</p>  <p>Before I get started on the first topic, I want to share some photos of the IRC client. Here are a couple screenshots from the day I started to where I am now:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/1050.before_6B169A5E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/1050.before_5F00_6B169A5E.png"><img title="Day 1" style="margin: 5px auto; float: none; display: block;" border="0" alt="Day 1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/0574.before_thumb_11787DAA.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/0574.before_5F00_thumb_5F00_11787DAA.png" width="304" height="171" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/1145.after_4D38165D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/1145.after_5F00_4D38165D.png"><img title="Day 7" style="margin: 5px auto; float: none; display: block;" border="0" alt="Day 7" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/55/91/metablogapi/6443.after_thumb_182B872D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-91-metablogapi/6443.after_5F00_thumb_5F00_182B872D.png" width="309" height="176" /></a></p>  <p>Even though there are many (many, many) improvements and features waiting to be done, I’m trilled about what I have accomplished so far.</p>  <h6>Using StreamSockets to initiate a TCP connection</h6>  <p>There are a huge number of cool and exciting new features that Windows 8 offers, bit if you've made the obvious decision to build a Windows 8 App, chances are your app will first need to connect to a remote service in some way before implementing anything else. That is why I’m starting off writing about (what I believe any Windows 8 developer should know) networking with the Windows 8 API. Of course, depending on the service and network protocol, there are different ways to accomplish the task, and the Windows 8 API makes it very easy to get your app connected in minutes, but I will specifically talk about communicating over a TCP connection.</p>  <p>To get started, I used a lot of readily available online resources that I think you should at least open in a new tab:</p>  <ul>   <li><a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/BR229573(v=win.10).aspx">Connecting to peers, web and network services</a></li>    <li><a href="https://code.msdn.microsoft.com/windowsapps/site/search?query=streamsocket&amp;f%5B0%5D.Value=streamsocket&amp;f%5B0%5D.Type=SearchText&amp;ac=3">Windows Store app samples</a></li>    <li><a href="https://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-580T">Building Windows runtime sockets apps</a></li>    <li><a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.streamsocket.aspx">StreamSocket class</a></li>    <li>and many more</li> </ul>  <p>The Windows 8 API defines a very useful object called StreamSocket that handles most of the TCP communication we need. StreamSocket and related classes belong to the <strong><a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.aspx" target="_blank">Windows.Networking</a></strong> and <strong><a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.aspx" target="_blank">Windows.Networking.Streams</a></strong> namespaces which also offer many other capabilities and classes such as connecting to a Web Service, reacting to Network Status changes, Background Data Transfer and more. If you want to learn more about other networking features with the Networking Namespace, I encourage you to visit <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/BR229573(v=win.10).aspx">https://msdn.microsoft.com/en-us/library/windows/apps/xaml/BR229573(v=win.10).aspx</a> .</p>  <p>Let’s get started. To initiate a TCP connection to a host, we will first need to know the Hostname or IP address of the machine and the remote port the service is attached to. Once we know the hostname and the port, we only need few lines of code to initiate a connection:</p>  <div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">   <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">     <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> StreamSocket socket = <span style="color: rgb(0, 0, 255);">new</span> StreamSocket();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum2" style="color: rgb(96, 96, 96);">   2:</span> HostName hostname = <span style="color: rgb(0, 0, 255);">new</span> HostName(<span style="color: rgb(0, 96, 128);">&quot;myremoteserver.net&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum3" style="color: rgb(96, 96, 96);">   3:</span> await socket.ConnectAsync(hostname, <span style="color: rgb(0, 96, 128);">&quot;80&quot;</span>);</pre>
<!--CRLF--></div>
</div>

<p>Congratulations, you are now connected to the target host. But what if the server is unreachable, or can’t receive any connections? To account for those scenarios, we use the wonderful try-catch statement. When a connection is unsuccessful, an exception is thrown which needs to be translated to a SocketErrorStatus that indicates the SocketError. Here is an example with the <strong>HostNotFound</strong> SocketErrorStatus:</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> <span style="color: rgb(0, 0, 255);">try</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum2" style="color: rgb(96, 96, 96);">   2:</span> {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum3" style="color: rgb(96, 96, 96);">   3:</span>     StreamSocket socket = <span style="color: rgb(0, 0, 255);">new</span> StreamSocket();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum4" style="color: rgb(96, 96, 96);">   4:</span>     HostName hostname = <span style="color: rgb(0, 0, 255);">new</span> HostName(<span style="color: rgb(0, 96, 128);">&quot;myremoteserver.net&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum5" style="color: rgb(96, 96, 96);">   5:</span>     await socket.ConnectAsync(hostname, <span style="color: rgb(0, 96, 128);">&quot;80&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum6" style="color: rgb(96, 96, 96);">   6:</span> }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum7" style="color: rgb(96, 96, 96);">   7:</span> <span style="color: rgb(0, 0, 255);">catch</span> (Exception exception)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum8" style="color: rgb(96, 96, 96);">   8:</span> {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum9" style="color: rgb(96, 96, 96);">   9:</span>     <span style="color: rgb(0, 0, 255);">switch</span> (SocketError.GetStatus(exception.HResult))</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum10" style="color: rgb(96, 96, 96);">  10:</span>     {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum11" style="color: rgb(96, 96, 96);">  11:</span>         <span style="color: rgb(0, 0, 255);">case</span> SocketErrorStatus.HostNotFound:</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum12" style="color: rgb(96, 96, 96);">  12:</span>             <span style="color: rgb(0, 128, 0);">// Handle HostNotFound Error</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum13" style="color: rgb(96, 96, 96);">  13:</span>             <span style="color: rgb(0, 0, 255);">break</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum14" style="color: rgb(96, 96, 96);">  14:</span>         <span style="color: rgb(0, 0, 255);">default</span>:</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum15" style="color: rgb(96, 96, 96);">  15:</span>             <span style="color: rgb(0, 128, 0);">// Handle Unknown Error</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum16" style="color: rgb(96, 96, 96);">  16:</span>             <span style="color: rgb(0, 0, 255);">break</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum17" style="color: rgb(96, 96, 96);">  17:</span>     }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum18" style="color: rgb(96, 96, 96);">  18:</span> }</pre>
<!--CRLF--></div>
</div>

<p>All possible SocketErrorStatus Members can be used in the same way. Their definitions can be found <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.socketerrorstatus.aspx" target="_blank">here</a>.</p>

<p>Great, now we can detect when a host is unreachable (or Connection Times out, etc) and we can react appropriately. Let’s move on to talking to the host service when the connection is successful.</p>

<p>The StreamSocket class is equipped with the InputStream and OutputStream Objects that are used to receive and send data accordingly. To make our lives easier (and shorten the code we have to write) we will use a <a href="https://msdn.microsoft.com/library/windows/apps/BR208119" target="_blank">DataReader</a> and <a href="https://msdn.microsoft.com/library/windows/apps/BR208154" target="_blank">DataWriter</a> to read and write to the data streams. The DataReader and DataWriter can be attached to a stream to simplify reading and writing, and to use them we need to instantiate them with the stream as input.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> <span style="color: rgb(0, 128, 0);">// the Windows.Storage.Streams Namespace contains</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum2" style="color: rgb(96, 96, 96);">   2:</span> <span style="color: rgb(0, 128, 0);">// the DataReader and DataWriter Objects</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum3" style="color: rgb(96, 96, 96);">   3:</span> <span style="color: rgb(0, 0, 255);">using</span> Windows.Storage.Streams;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum4" style="color: rgb(96, 96, 96);">   4:</span>&#160; </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum5" style="color: rgb(96, 96, 96);">   5:</span> <span style="color: rgb(0, 128, 0);">// add after calling ConnectAsync on the StreamSocket Object</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum6" style="color: rgb(96, 96, 96);">   6:</span> DataReader reader = <span style="color: rgb(0, 0, 255);">new</span> DataReader(socket.InputStream);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum7" style="color: rgb(96, 96, 96);">   7:</span> DataWriter writer = <span style="color: rgb(0, 0, 255);">new</span> DataWriter(socket.OutputStream);</pre>
<!--CRLF--></div>
</div>

<p>To send data to the host, first we need to write the data to the DataWriter by calling one of the DataWriter.Write* methods, and finally committing the data by calling the StoreAsync method. The DataWriter handles the rest.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> <span style="color: rgb(0, 128, 0);">// write a string to the OutputStream</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum2" style="color: rgb(96, 96, 96);">   2:</span> writer.WriteString(<span style="color: rgb(0, 96, 128);">&quot;some data to send to host&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum3" style="color: rgb(96, 96, 96);">   3:</span>&#160; </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum4" style="color: rgb(96, 96, 96);">   4:</span> <span style="color: rgb(0, 128, 0);">// commit and send the data in the OutputStream</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum5" style="color: rgb(96, 96, 96);">   5:</span> await writer.StoreAsync();</pre>
<!--CRLF--></div>
</div>

<p> And the data has been sent.</p>

<p>Receiving data is very similar to sending data, but with few differences. To receive data, we need to tell the DataReader how much data to receive and we need to wait for the data to be available. However, most of the times we don’t know how much data will be sent. Luckily, we can tell the DataReader to receive only the available data (up to a certain count) by setting the <strong>InputStreamOptions</strong> to <strong>Partial</strong>. And after the raw data has been received, we can call one of the DataReader.Read* methods to retrieve it:</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum1" style="color: rgb(96, 96, 96);">   1:</span> <span style="color: rgb(0, 128, 0);">// container for the received Data</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum2" style="color: rgb(96, 96, 96);">   2:</span> <span style="color: rgb(0, 128, 0);">// in this case a string</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum3" style="color: rgb(96, 96, 96);">   3:</span> <span style="color: rgb(0, 0, 255);">string</span> receivedData;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum4" style="color: rgb(96, 96, 96);">   4:</span>&#160; </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum5" style="color: rgb(96, 96, 96);">   5:</span> <span style="color: rgb(0, 128, 0);">// set the DataReader to only wait for available data</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum6" style="color: rgb(96, 96, 96);">   6:</span> reader.InputStreamOptions = InputStreamOptions.Partial;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum7" style="color: rgb(96, 96, 96);">   7:</span>&#160; </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum8" style="color: rgb(96, 96, 96);">   8:</span> <span style="color: rgb(0, 128, 0);">// wait for the available data up to 512 bytes</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum9" style="color: rgb(96, 96, 96);">   9:</span> <span style="color: rgb(0, 128, 0);">// count is the number of actually received bytes</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum10" style="color: rgb(96, 96, 96);">  10:</span> var count = await reader.LoadAsync(512);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum11" style="color: rgb(96, 96, 96);">  11:</span>&#160; </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum12" style="color: rgb(96, 96, 96);">  12:</span> <span style="color: rgb(0, 128, 0);">// read the data as a string and store it in our container</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span id="lnum13" style="color: rgb(96, 96, 96);">  13:</span> <span style="color: rgb(0, 0, 255);">if</span> (count &gt; 0)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span id="lnum14" style="color: rgb(96, 96, 96);">  14:</span>     receivedData = reader.ReadString(count);</pre>
<!--CRLF--></div>
</div>

<p>Now you can process the received data and start receiving or sending data again.</p>

<h6>Using StreamSocket for IRC communication</h6>

<p>Most of the work is already done and we only need to process the data we receive. Because of the IRC protocol, the TCP client is required to listen for incoming data constantly, so I created a new Event that would be called each time a new string line was available and go back to listening for data. I created a new IRCClient class that would handle the IRC implementation and I created a method that I attached to the TCP Client event to handle each line as it is received. This way, all the IRC work is done by the IRCClient class, and the TCP client can go back to start listening for data again without delay.</p>]]></content:encoded>
    </item>
    <item>
      <title>Hello, World!</title>
      <link>https://docs.microsoft.com/archive/blogs/metulev/hello-world</link>
      <pubDate>Fri, 05 Oct 2012 12:14:38 GMT</pubDate>
      <dc:creator><![CDATA[Nikola Metulev]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/metulev/2012/10/05/hello-world/</guid>
      <description><![CDATA[Hello there, and welcome to my very first blog entry.
My name is Nikola Metulev. I recently...]]></description>
      <content:encoded><![CDATA[<p>Hello there, and welcome to my very first blog entry.</p>
<p>My name is Nikola Metulev. I recently graduated from UC Irvine (Go Anteaters) with a degree in Computer Science and Engineering, moved from Orange County to the Seattle area, and started working as a Windows 8 Developer Evangelist at Microsoft.</p>
<p>The purpose of my blog is to document the process of developing cool projects around Windows 8. So get ready to learn about my experiences in developing some amazing Apps.</p>]]></content:encoded>
    </item>
  </channel>
</rss>