changeset 12:9129c437b1a3

move RewritingTest Directory
author riono <e165729@ie.u-ryukyu.ac.jp>
date Thu, 19 Nov 2020 16:46:00 +0900
parents 1f7d4f168b89
children e4b46d4ef79c
files Christie_net.csproj RewritingTest/ParseAddress.cs RewritingTest/Program.cs RewritingTest/SocketIPPortCheck.cs Test/RewritingTest/ParseAddress.cs Test/RewritingTest/Program.cs Test/RewritingTest/SocketIPPortCheck.cs daemon/Connection.cs
diffstat 8 files changed, 174 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/Christie_net.csproj	Thu Nov 19 03:05:28 2020 +0900
+++ b/Christie_net.csproj	Thu Nov 19 16:46:00 2020 +0900
@@ -10,4 +10,8 @@
       <PackageReference Include="MessagePack" Version="2.1.143" />
     </ItemGroup>
 
+    <ItemGroup>
+      <Folder Include="Test" />
+    </ItemGroup>
+
 </Project>
--- a/RewritingTest/ParseAddress.cs	Thu Nov 19 03:05:28 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-using System;
-using System.Net;
-
-class ParseAddress
-{
-
-    private static void Main(string[] args)
-    {
-        string IPaddress;
-
-        if (args.Length == 0)
-        {
-            Console.WriteLine("Please enter an IP address.");
-            Console.WriteLine("Usage:   >cs_parse any IPv4 or IPv6 address.");
-            Console.WriteLine("Example: >cs_parse 127.0.0.1");
-            Console.WriteLine("Example: >cs_parse 0:0:0:0:0:0:0:1");
-            return;
-        }
-        else
-        {
-            IPaddress = args[0];
-        }
-
-        // Get the list of the IPv6 addresses associated with the requested host.
-        Parse(IPaddress);
-    }
-
-    // This method calls the IPAddress.Parse method to check the ipAddress
-    // input string. If the ipAddress argument represents a syntatically correct IPv4 or
-    // IPv6 address, the method displays the Parse output into quad-notation or
-    // colon-hexadecimal notation, respectively. Otherwise, it displays an
-    // error message.
-    private static void Parse(string ipAddress)
-    {
-        try
-        {
-            // Create an instance of IPAddress for the specified address string (in
-            // dotted-quad, or colon-hexadecimal notation).
-            IPAddress address = IPAddress.Parse(ipAddress);
-
-            // Display the address in standard notation.
-            Console.WriteLine("Parsing your input string: " + "\"" + ipAddress + "\"" + " produces this address (shown in its standard notation): "+ address.ToString());
-        }
-
-        catch(ArgumentNullException e)
-        {
-            Console.WriteLine("ArgumentNullException caught!!!");
-            Console.WriteLine("Source : " + e.Source);
-            Console.WriteLine("Message : " + e.Message);
-        }
-
-        catch(FormatException e)
-        {
-            Console.WriteLine("FormatException caught!!!");
-            Console.WriteLine("Source : " + e.Source);
-            Console.WriteLine("Message : " + e.Message);
-        }
-
-        catch(Exception e)
-        {
-            Console.WriteLine("Exception caught!!!");
-            Console.WriteLine("Source : " + e.Source);
-            Console.WriteLine("Message : " + e.Message);
-        }
-    }
-}
\ No newline at end of file
--- a/RewritingTest/Program.cs	Thu Nov 19 03:05:28 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-using System;
-
-namespace Christie_net {
-internal class Program {
-    //[Peek] Test testindex;
-
-    private static void Main(string[] args) {
-        Console.WriteLine("Hello World!");
-    }
-}
-}
\ No newline at end of file
--- a/RewritingTest/SocketIPPortCheck.cs	Thu Nov 19 03:05:28 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-using System;
-using System.Net;
-using System.Net.Sockets;
-
-// socketを作成してIPとportを取得する 作動にはListenerが必要
-class SocketIPPortCheck {
-    public void SetSocket() {
-        IPHostEntry host = Dns.GetHostEntry("localhost");
-        IPAddress ipAddress = host.AddressList[0];
-        //IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
-        IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
-
-        // Create a TCP/IP  socket.    
-        Socket sender = new Socket(ipAddress.AddressFamily,
-            SocketType.Stream, ProtocolType.Tcp);
-
-        sender.Connect(remoteEP);
-
-        Console.WriteLine(Dns.GetHostEntry(((IPEndPoint)sender.RemoteEndPoint).Address.ToString()).HostName + ":" +
-                          ((IPEndPoint) sender.RemoteEndPoint).Port.ToString());
-    }
-
-    private static void Main(string[] args) {
-        SocketIPPortCheck check = new SocketIPPortCheck();
-        check.SetSocket();
-    }
-}
-
-// Listenerのコード
-// using System;
-// using System.Net;
-// using System.Net.Sockets;
-// using System.Text;
-//
-// // Socket Listener acts as a server and listens to the incoming   
-// // messages on the specified port and protocol.  
-// public class SocketListener {
-//     public static int Main (String[] args) {
-//         StartServer ();
-//         return 0;
-//     }
-//
-//     public static void StartServer () {
-//         // Get Host IP Address that is used to establish a connection  
-//         // In this case, we get one IP address of localhost that is IP : 127.0.0.1  
-//         // If a host has multiple addresses, you will get a list of addresses  
-//         IPHostEntry host = Dns.GetHostEntry ("localhost");
-//         IPAddress ipAddress = host.AddressList[0];
-// 	//IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
-// 	IPEndPoint localEndPoint = new IPEndPoint (ipAddress, 11000);
-//
-//         try {
-//
-//             // Create a Socket that will use Tcp protocol      
-//             Socket listener = new Socket (ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
-//             // A Socket must be associated with an endpoint using the Bind method  
-//             listener.Bind (localEndPoint);
-//             // Specify how many requests a Socket can listen before it gives Server busy response.  
-//             // We will listen 10 requests at a time  
-//             listener.Listen (10);
-//
-//             Console.WriteLine ("Waiting for a connection...");
-//             Socket handler = listener.Accept ();
-//
-//             // Incoming data from the client.    
-//             string data = null;
-//             byte[] bytes = null;
-//
-//             while (true) {
-//                 bytes = new byte[1024];
-//                 int bytesRec = handler.Receive (bytes);
-//                 data += Encoding.ASCII.GetString (bytes, 0, bytesRec);
-//                 if (data.IndexOf ("<EOF>") > -1) {
-//                     break;
-//                 }
-//             }
-//
-//             Console.WriteLine ("Text received : {0}", data);
-//
-//             byte[] msg = Encoding.ASCII.GetBytes (data);
-//             handler.Send (msg);
-//             handler.Shutdown (SocketShutdown.Both);
-//             handler.Close ();
-//         } catch (Exception e) {
-//             Console.WriteLine (e.ToString ());
-//         }
-//
-//         Console.WriteLine ("\n Press any key to continue...");
-//         Console.ReadKey ();
-//     }
-//}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/RewritingTest/ParseAddress.cs	Thu Nov 19 16:46:00 2020 +0900
@@ -0,0 +1,66 @@
+using System;
+using System.Net;
+
+class ParseAddress
+{
+
+    private static void Main(string[] args)
+    {
+        string IPaddress;
+
+        if (args.Length == 0)
+        {
+            Console.WriteLine("Please enter an IP address.");
+            Console.WriteLine("Usage:   >cs_parse any IPv4 or IPv6 address.");
+            Console.WriteLine("Example: >cs_parse 127.0.0.1");
+            Console.WriteLine("Example: >cs_parse 0:0:0:0:0:0:0:1");
+            return;
+        }
+        else
+        {
+            IPaddress = args[0];
+        }
+
+        // Get the list of the IPv6 addresses associated with the requested host.
+        Parse(IPaddress);
+    }
+
+    // This method calls the IPAddress.Parse method to check the ipAddress
+    // input string. If the ipAddress argument represents a syntatically correct IPv4 or
+    // IPv6 address, the method displays the Parse output into quad-notation or
+    // colon-hexadecimal notation, respectively. Otherwise, it displays an
+    // error message.
+    private static void Parse(string ipAddress)
+    {
+        try
+        {
+            // Create an instance of IPAddress for the specified address string (in
+            // dotted-quad, or colon-hexadecimal notation).
+            IPAddress address = IPAddress.Parse(ipAddress);
+
+            // Display the address in standard notation.
+            Console.WriteLine("Parsing your input string: " + "\"" + ipAddress + "\"" + " produces this address (shown in its standard notation): "+ address.ToString());
+        }
+
+        catch(ArgumentNullException e)
+        {
+            Console.WriteLine("ArgumentNullException caught!!!");
+            Console.WriteLine("Source : " + e.Source);
+            Console.WriteLine("Message : " + e.Message);
+        }
+
+        catch(FormatException e)
+        {
+            Console.WriteLine("FormatException caught!!!");
+            Console.WriteLine("Source : " + e.Source);
+            Console.WriteLine("Message : " + e.Message);
+        }
+
+        catch(Exception e)
+        {
+            Console.WriteLine("Exception caught!!!");
+            Console.WriteLine("Source : " + e.Source);
+            Console.WriteLine("Message : " + e.Message);
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/RewritingTest/Program.cs	Thu Nov 19 16:46:00 2020 +0900
@@ -0,0 +1,11 @@
+using System;
+
+namespace Christie_net {
+internal class Program {
+    //[Peek] Test testindex;
+
+    private static void Main(string[] args) {
+        Console.WriteLine("Hello World!");
+    }
+}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/RewritingTest/SocketIPPortCheck.cs	Thu Nov 19 16:46:00 2020 +0900
@@ -0,0 +1,92 @@
+using System;
+using System.Net;
+using System.Net.Sockets;
+
+// socketを作成してIPとportを取得する 作動にはListenerが必要
+class SocketIPPortCheck {
+    public void SetSocket() {
+        IPHostEntry host = Dns.GetHostEntry("localhost");
+        IPAddress ipAddress = host.AddressList[0];
+        //IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
+        IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
+
+        // Create a TCP/IP  socket.    
+        Socket sender = new Socket(ipAddress.AddressFamily,
+            SocketType.Stream, ProtocolType.Tcp);
+
+        sender.Connect(remoteEP);
+
+        Console.WriteLine(Dns.GetHostEntry(((IPEndPoint)sender.RemoteEndPoint).Address.ToString()).HostName + ":" +
+                          ((IPEndPoint) sender.RemoteEndPoint).Port.ToString());
+    }
+
+    private static void Main(string[] args) {
+        SocketIPPortCheck check = new SocketIPPortCheck();
+        check.SetSocket();
+    }
+}
+
+// Listenerのコード
+// using System;
+// using System.Net;
+// using System.Net.Sockets;
+// using System.Text;
+//
+// // Socket Listener acts as a server and listens to the incoming   
+// // messages on the specified port and protocol.  
+// public class SocketListener {
+//     public static int Main (String[] args) {
+//         StartServer ();
+//         return 0;
+//     }
+//
+//     public static void StartServer () {
+//         // Get Host IP Address that is used to establish a connection  
+//         // In this case, we get one IP address of localhost that is IP : 127.0.0.1  
+//         // If a host has multiple addresses, you will get a list of addresses  
+//         IPHostEntry host = Dns.GetHostEntry ("localhost");
+//         IPAddress ipAddress = host.AddressList[0];
+// 	//IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
+// 	IPEndPoint localEndPoint = new IPEndPoint (ipAddress, 11000);
+//
+//         try {
+//
+//             // Create a Socket that will use Tcp protocol      
+//             Socket listener = new Socket (ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
+//             // A Socket must be associated with an endpoint using the Bind method  
+//             listener.Bind (localEndPoint);
+//             // Specify how many requests a Socket can listen before it gives Server busy response.  
+//             // We will listen 10 requests at a time  
+//             listener.Listen (10);
+//
+//             Console.WriteLine ("Waiting for a connection...");
+//             Socket handler = listener.Accept ();
+//
+//             // Incoming data from the client.    
+//             string data = null;
+//             byte[] bytes = null;
+//
+//             while (true) {
+//                 bytes = new byte[1024];
+//                 int bytesRec = handler.Receive (bytes);
+//                 data += Encoding.ASCII.GetString (bytes, 0, bytesRec);
+//                 if (data.IndexOf ("<EOF>") > -1) {
+//                     break;
+//                 }
+//             }
+//
+//             Console.WriteLine ("Text received : {0}", data);
+//
+//             byte[] msg = Encoding.ASCII.GetBytes (data);
+//             handler.Send (msg);
+//             handler.Shutdown (SocketShutdown.Both);
+//             handler.Close ();
+//         } catch (Exception e) {
+//             Console.WriteLine (e.ToString ());
+//         }
+//
+//         Console.WriteLine ("\n Press any key to continue...");
+//         Console.ReadKey ();
+//     }
+//}
+
--- a/daemon/Connection.cs	Thu Nov 19 03:05:28 2020 +0900
+++ b/daemon/Connection.cs	Thu Nov 19 16:46:00 2020 +0900
@@ -35,7 +35,7 @@
     }
 
     public void Close() {
-        //socket
+        socket.Close();
     }
 
     public void Write(Command cmd) {