<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lesnikowski Blog &#187; mono</title>
	<atom:link href="http://www.lesnikowski.com/blog/index.php/tag/mono/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lesnikowski.com/blog</link>
	<description>.Net</description>
	<lastBuildDate>Wed, 28 Jul 2010 10:10:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A non-blocking socket operation could not be completed</title>
		<link>http://www.lesnikowski.com/blog/index.php/a-non-blocking-socket-operation/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-non-blocking-socket-operation</link>
		<comments>http://www.lesnikowski.com/blog/index.php/a-non-blocking-socket-operation/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 16:03:29 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[mono]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=809</guid>
		<description><![CDATA[There is a bug in .NET 2.0 regarding timeout handling by Socket class.
Here&#8217;s the code that reproduces this behavior. 

using(TcpClient client = new TcpClient())
{
    // Set timeout
    client.ReceiveTimeout =
        (int)TimeSpan.FromSeconds(1).TotalMilliseconds;

    // Connect to perfectly working imap server
   [...]]]></description>
			<content:encoded><![CDATA[<p>There is a bug in .NET 2.0 regarding timeout handling by Socket class.<br />
Here&#8217;s the code that reproduces this behavior. </p>
<pre class="brush: csharp;">
using(TcpClient client = new TcpClient())
{
    // Set timeout
    client.ReceiveTimeout =
        (int)TimeSpan.FromSeconds(1).TotalMilliseconds;

    // Connect to perfectly working imap server
    client.Connect(&quot;mail.lesnikowski.com&quot;, 143);

    // Create reader &amp; writer
    NetworkStream stream = client.GetStream();
    StreamReader reader = new StreamReader(stream);
    StreamWriter writer = new StreamWriter(stream);

    // Read hello line
    Console.WriteLine(reader.ReadLine());

    // this works with no problems
    writer.WriteLine(&quot;a NOOP&quot;);             // No operation command
    writer.Flush();
    Console.WriteLine(reader.ReadLine());   // No operation response

    try
    {
        reader.ReadLine();                  // Nothing to read
    }
    catch (Exception ex)                    // Timeout
    {
        Console.WriteLine(&quot;timeout&quot;);       // This is expected
    }

    writer.WriteLine(&quot;b NOOP&quot;);             // No operation command
    writer.Flush();

    // SocketException: A non-blocking socket operation
    // could not be completed immediately
    Console.WriteLine(reader.ReadLine());   

    client.Close();
}
</pre>
<p>The above code runs as expected on Mono and on .NET 4.0.</p>
<p>The problem is in UpdateStatusAfterSocketError internal Socket method that executes SetToDisconnected method when any exception is thrown, including timeout exception.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/a-non-blocking-socket-operation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Regex bug on Mono</title>
		<link>http://www.lesnikowski.com/blog/index.php/regex-bug-on-mono/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=regex-bug-on-mono</link>
		<comments>http://www.lesnikowski.com/blog/index.php/regex-bug-on-mono/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 12:36:19 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mono]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=345</guid>
		<description><![CDATA[This is a good advice for all creating applications using .NET that need to work on both Microsoft .NET and Mono.
It seems that Mono ignores group indexes specified explicitly.
Here&#8217;s the code to reproduce this problem. And the results on Mono are incorrect.

Regex parser = new Regex(&#34;(?&#60;2&#62;.*?),(?&#60;1&#62;.*?),&#34;);
Match match = parser.Match(&#34;first,second,&#34;);
Console.WriteLine(&#34;Groups[1].Value={0}&#34;, match.Groups[1].Value);
Console.WriteLine(&#34;Groups[2].Value={0}&#34;, match.Groups[2].Value);

MS implementation:

C:\1\ConsoleApplication1\bin\Debug&#62;ConsoleApplication1.exe
Groups[1].Value=second
Groups[2].Value=first

Mono 2.4.2.3 implementation:

C:\1\ConsoleApplication1\bin\Debug&#62;mono.exe ConsoleApplication1.exe
Groups[1].Value=first
Groups[2].Value=second

The [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2009/12/mono.png" alt="mono" title="mono" width="83" height="100" class="alignleft size-full wp-image-347" />This is a good advice for all creating applications using .NET that need to work on both Microsoft .NET and Mono.</p>
<p>It seems that Mono ignores group indexes specified explicitly.<br />
Here&#8217;s the code to reproduce this problem. And the results on Mono are incorrect.</p>
<pre class="brush: csharp;">
Regex parser = new Regex(&quot;(?&lt;2&gt;.*?),(?&lt;1&gt;.*?),&quot;);
Match match = parser.Match(&quot;first,second,&quot;);
Console.WriteLine(&quot;Groups[1].Value={0}&quot;, match.Groups[1].Value);
Console.WriteLine(&quot;Groups[2].Value={0}&quot;, match.Groups[2].Value);
</pre>
<p>MS implementation:</p>
<pre class="brush: plain;">
C:\1\ConsoleApplication1\bin\Debug&gt;ConsoleApplication1.exe
Groups[1].Value=second
Groups[2].Value=first
</pre>
<p>Mono 2.4.2.3 implementation:</p>
<pre class="brush: plain;">
C:\1\ConsoleApplication1\bin\Debug&gt;mono.exe ConsoleApplication1.exe
Groups[1].Value=first
Groups[2].Value=second
</pre>
<p>The workaround is simple use names instead of numbers:</p>
<pre class="brush: csharp;">
Regex parser = new Regex(&quot;(?&lt;first&gt;.*?),(?&lt;second&gt;.*?),&quot;);
Match match = parser.Match(&quot;first,second,&quot;);
Console.WriteLine(&quot;Groups[first].Value={0}&quot;, match.Groups[&quot;first&quot;].Value);
Console.WriteLine(&quot;Groups[second].Value={0}&quot;, match.Groups[&quot;second&quot;].Value);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/regex-bug-on-mono/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
