{"id":11249,"date":"2017-01-18T10:47:16","date_gmt":"2017-01-18T01:47:16","guid":{"rendered":"http:\/\/agrimo.jp\/wp\/?page_id=11249"},"modified":"2017-08-29T15:33:56","modified_gmt":"2017-08-29T06:33:56","slug":"%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%ef%bc%91","status":"publish","type":"page","link":"https:\/\/agrimo.jp\/wp\/?page_id=11249","title":{"rendered":"\u30b5\u30f3\u30d7\u30eb\uff11"},"content":{"rendered":"<p>TCP\u30bd\u30b1\u30c3\u30c8\u901a\u4fe1\u3067\u3072\u304b\u308a\u96fb\u8a71\uff23\uff34\uff29\uff08CTI\u30b5\u30fc\u30d0\u30fc\uff09\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001\u96fb\u8a71\u7740\u4fe1\u304c\u3042\u3063\u305f\u6642\u306b\u7740\u4fe1\u60c5\u5831\u3092\u53d7\u4fe1\u3059\u308bc#\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<p>\uff1c\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3000c#\uff1e<\/p>\n<pre title=\"TCP\u30bd\u30b1\u30c3\u30c8\u901a\u4fe1\u3067CTI\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u7740\u4fe1\u60c5\u5831\u3092\u53d7\u4fe1\u3059\u308b\" class=\"lang:default decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace HikariCTI_Sample_001\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            \/\/\u30b5\u30fc\u30d0\u30fc\u306eIP\u30a2\u30c9\u30ec\u30b9\uff08\u307e\u305f\u306f\u3001\u30db\u30b9\u30c8\u540d\uff09\u3068\u30dd\u30fc\u30c8\u756a\u53f7\r\n            string ipOrHost = \"192.168.24.9\";\r\n            int port = 3000;\r\n\r\n            \/\/TcpClient\u3092\u4f5c\u6210\u3057\u3001\u30b5\u30fc\u30d0\u30fc\u3068\u63a5\u7d9a\u3059\u308b\r\n            System.Net.Sockets.TcpClient tcp =\r\n                new System.Net.Sockets.TcpClient(ipOrHost, port);\r\n            Console.WriteLine(\"\u30b5\u30fc\u30d0\u30fc({0}:{1})\u3068\u63a5\u7d9a\u3057\u307e\u3057\u305f\u3002\u3000(\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP: {2}:{3})\",\r\n                ((System.Net.IPEndPoint)tcp.Client.RemoteEndPoint).Address,\r\n                ((System.Net.IPEndPoint)tcp.Client.RemoteEndPoint).Port,\r\n                ((System.Net.IPEndPoint)tcp.Client.LocalEndPoint).Address,\r\n                ((System.Net.IPEndPoint)tcp.Client.LocalEndPoint).Port);\r\n\r\n            Console.WriteLine(\"\\r\\n\u7740\u4fe1\u5f85\u3061\u3092\u958b\u59cb\u3057\u307e\u3057\u305f\u3002\\r\\n\");\r\n\r\n            \/\/NetworkStream\u3092\u53d6\u5f97\u3059\u308b\r\n            System.Net.Sockets.NetworkStream ns = tcp.GetStream();\r\n\r\n            \/\/\u8aad\u307f\u53d6\u308a\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u309210\u79d2\u306b\u3059\u308b\r\n            \/\/ns.ReadTimeout = 10000;\r\n\r\n            \/\/\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001SJIS\r\n            System.Text.Encoding enc = System.Text.Encoding.GetEncoding(\"shift-jis\");\r\n\r\n            \/\/\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u9001\u3089\u308c\u305f\u30c7\u30fc\u30bf\u3092\u53d7\u4fe1\u3059\u308b\r\n            System.IO.MemoryStream ms = new System.IO.MemoryStream();\r\n            byte[] resBytes = new byte[256];\r\n            int resSize = 0;\r\n            do\r\n            {\r\n                \/\/\u30c7\u30fc\u30bf\u306e\u4e00\u90e8\u3092\u53d7\u4fe1\u3059\u308b\r\n                resSize = ns.Read(resBytes, 0, resBytes.Length);\r\n                \/\/Read\u304c0\u3092\u8fd4\u3057\u305f\u6642\u306f\u30b5\u30fc\u30d0\u30fc\u304c\u5207\u65ad\u3057\u305f\u3068\u5224\u65ad\r\n                if (resSize == 0)\r\n                {\r\n                    Console.WriteLine(\"\u30b5\u30fc\u30d0\u30fc\u304c\u5207\u65ad\u3057\u307e\u3057\u305f\u3002\");\r\n                    break;\r\n                }\r\n                \/\/\u53d7\u4fe1\u3057\u305f\u30c7\u30fc\u30bf\u3092\u84c4\u7a4d\u3059\u308b\r\n                ms.Write(resBytes, 0, resSize);\r\n                \/\/\u307e\u3060\u8aad\u307f\u53d6\u308c\u308b\u30c7\u30fc\u30bf\u304c\u3042\u308b\u304b\u3001\u30c7\u30fc\u30bf\u306e\u6700\u5f8c\u304c\\n\u3067\u306a\u3044\u6642\u306f\u3001\r\n                \/\/ \u53d7\u4fe1\u3092\u7d9a\u3051\u308b\r\n            } while (ns.DataAvailable || resBytes[resSize - 1] != '\\n');\r\n            \/\/\u53d7\u4fe1\u3057\u305f\u30c7\u30fc\u30bf\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\r\n            string resMsg = enc.GetString(ms.GetBuffer(), 0, (int)ms.Length);\r\n            ms.Close();\r\n            \/\/\u672b\u5c3e\u306e\\n\u3092\u524a\u9664\r\n            resMsg = resMsg.TrimEnd('\\n');\r\n            Console.WriteLine(resMsg);\r\n\r\n            \/\/\u9589\u3058\u308b\r\n            ns.Close();\r\n            tcp.Close();\r\n            Console.WriteLine(\"\u5207\u65ad\u3057\u307e\u3057\u305f\u3002\");\r\n\r\n            Console.ReadLine();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\uff1c\u30b5\u30f3\u30d7\u30eb\u753b\u9762\uff11\u3000\uff1a\u3000\u7740\u4fe1\u5f85\u3061\u53d7\u3051\u4e2d\uff1e<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105727-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-13868\" src=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105727-1-300x126.png\" alt=\"\" width=\"300\" height=\"126\" srcset=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105727-1-300x126.png 300w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105727-1.png 778w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"padding-left: 30px;\">\n<p>\uff1c\u30b5\u30f3\u30d7\u30eb\u753b\u9762\uff12\u3000\uff1a\u3000\u5916\u7dda\u7740\u4fe1\u4e2d\uff1e<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105743-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-13869\" src=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105743-1-300x126.png\" alt=\"\" width=\"300\" height=\"126\" srcset=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105743-1-300x126.png 300w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2017\/01\/QS_20160910-105743-1.png 778w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"padding-left: 30px;\">\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TCP\u30bd\u30b1\u30c3\u30c8\u901a\u4fe1\u3067\u3072\u304b\u308a\u96fb\u8a71\uff23\uff34\uff29\uff08CTI\u30b5\u30fc\u30d0\u30fc\uff09\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001\u96fb\u8a71\u7740\u4fe1\u304c\u3042\u3063\u305f\u6642\u306b\u7740\u4fe1\u60c5\u5831\u3092\u53d7\u4fe1\u3059\u308bc# [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-11249","page","type-page","status-publish","hentry"],"wppr_data":{"cwp_meta_box_check":"No"},"_links":{"self":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages\/11249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11249"}],"version-history":[{"count":8,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages\/11249\/revisions"}],"predecessor-version":[{"id":13870,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages\/11249\/revisions\/13870"}],"wp:attachment":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}