[Mono-bugs] [Bug 42584][Wis] Changed - TcpClient.Close not close Socket
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Wed, 14 May 2003 07:21:04 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by lda@lupa.pl.
http://bugzilla.ximian.com/show_bug.cgi?id=42584
--- shadow/42584 Fri May 9 21:55:46 2003
+++ shadow/42584.tmp.22232 Wed May 14 07:21:04 2003
@@ -1,12 +1,12 @@
Bug#: 42584
Product: Mono/Class Libraries
Version: unspecified
OS: unknown
OS Details: Gentoo
-Status: NEEDINFO
+Status: REOPENED
Resolution:
Severity: Unknown
Priority: Wishlist
Component: System
AssignedTo: mono-bugs@ximian.com
ReportedBy: lda@lupa.pl
@@ -18,6 +18,75 @@
TcpClient class not close opened Socket at method Close on this object. Why?
Only just using GC.Collect() close this Socket.
------- Additional Comments From gonzalo@ximian.com 2003-05-09 21:55 -------
Can you please provide a test case for this?
+
+------- Additional Comments From lda@lupa.pl 2003-05-14 07:21 -------
+ok, this is test case
+
+--- server.cs
+public class Server {
+ static void Main() {
+ IPAddress ip = IPAddress.Parse("127.0.0.1");
+ TcpListener listener = new TcpListener(ip, 8001);
+ listener.Start();
+ int i = 0;
+ while(true) {
+ TcpClient client = listener.AcceptTcpClient();
+ System.Console.WriteLine(++i);
+ client.Close();
+ }
+ }
+}
+--- client.cs
+public class Client {
+ static void Main() {
+ for(int i=0;i<1000;i++) {
+ TcpClient client = new TcpClient();
+ client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8001));
+ System.Console.WriteLine(++i);
+ client.Close();
+ }
+ }
+}
+
+----
+0. in terminal type ulimit -n, if result is 1024 it's ok, else set
+ulimit -Sn 1024
+1. compile and run server.cs in terminal no. 1
+2. compile and run client.cs in terminal no. 2
+3. results.
+in terminal 1:
+...
+933
+934
+935
+
+Unhandled Exception: System.Net.Sockets.SocketException: Some sort of
+w32 error
+occurred: 10024
+in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x1f)
+[0x4009c3b2]
+in (unmanaged) /usr/lib/libmono.so.0 [0x400b7403]
+in <0x00019> 00 System.Net.Sockets.Socket:Accept ()
+in <0x00014> 00 System.Net.Sockets.TcpListener:AcceptSocket ()
+in <0x00041> 00 System.Net.Sockets.TcpListener:AcceptTcpClient ()
+in <0x00088> 00 .Server:Main ()
+
+in terminal 2:
+...
+1867
+1869
+1871
+
+Unhandled Exception: System.Net.Sockets.SocketException: Connection
+refused
+in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x1f)
+[0x4009c3b2]
+in (unmanaged) /usr/lib/libmono.so.0 [0x400b7a6c]
+in <0x00059> 00 System.Net.Sockets.Socket:Connect (System.Net.EndPoint)
+in <0x00017> 00 System.Net.Sockets.TcpClient:Connect
+(System.Net.IPEndPoint)
+in <0x0009d> 00 .Client:Main ()
+