1 // System.Net.Sockets.NetworkStreamTest.cs
4 // Dick Porter (dick@ximian.com)
6 // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
9 using System.Net.Sockets;
13 using NUnit.Framework;
16 namespace MonoTests.System.Net.Sockets
19 public class NetworkStreamTest
23 public void ReadTimeout ()
25 Socket sock = new Socket (AddressFamily.InterNetwork,
28 Socket listen = new Socket (AddressFamily.InterNetwork,
31 IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 0);
36 sock.Connect (listen.LocalEndPoint);
38 NetworkStream stream = new NetworkStream (sock);
39 stream.ReadTimeout = 1000;
41 byte[] buf = new byte[1024];
44 stream.Read (buf, 0, buf.Length);
45 Assert.Fail ("ReadTimeout #1");
46 } catch (IOException ex) {
47 Exception inner = ex.InnerException;
48 SocketException sockex = inner as SocketException;
50 Assert.IsNotNull (sockex, "ReadTimeout #2");
52 /* Linux gives error 10035 (EWOULDBLOCK) here, whereas windows has 10060 (ETIMEDOUT)
53 Assertion.AssertEquals ("ReadTimeout #3",
58 Assert.Fail ("ReadTimeout #4");