{"id":55,"date":"2019-09-18T19:25:02","date_gmt":"2019-09-18T10:25:02","guid":{"rendered":"http:\/\/drroot.page\/wp\/?p=55"},"modified":"2019-11-21T19:31:55","modified_gmt":"2019-11-21T10:31:55","slug":"bizhawk%e3%82%a8%e3%83%9f%e3%83%a5%e3%81%8b%e3%82%89socket%e3%82%92%e9%a3%9b%e3%81%b0%e3%81%99%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/drroot.page\/wp\/?p=55","title":{"rendered":"BizHawk\u30a8\u30df\u30e5\u304b\u3089Socket\u3092\u98db\u3070\u3059\u65b9\u6cd5"},"content":{"rendered":"<h2>\u3084\u308a\u305f\u3044\u3053\u3068<\/h2>\n<p>\u7d71\u5408\u30a8\u30df\u30e5\u3067\u3042\u308b<a href=\"https:\/\/github.com\/TASVideos\/BizHawk\">BizHawk<\/a>\u304b\u3089\u3001Lua\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4ecb\u3057\u3066Socket\u3092\u767a\u4fe1\u3059\u308b\u3002<br \/>\n\u3053\u308c\u304c\u3067\u304d\u308b\u3068\u3001\u4f8b\u3048\u3070\u30b2\u30fc\u30e0\u5185\u306e\u30e1\u30e2\u30ea\u30c7\u30fc\u30bf\u3092\u30c0\u30f3\u30d7\u3057\u3001Lua\u3092\u4ecb\u3057\u3066\u5225\u30a2\u30d7\u30ea\u306bSocket\u9001\u4fe1\u304c\u3067\u304d\u308b\u306e\u3067\u3001Lua\u3067\u306f\u51fa\u6765\u306a\u3044OS\u306e\u6a5f\u80fd\u3092\u3044\u304f\u3089\u3067\u3082\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p><!--more--><\/p>\n<h2>BizHawk\u5074\u3067\u3084\u308b\u3053\u3068<\/h2>\n<p>BizHawk\u306f\u81ea\u524d\u306eSocket\u901a\u4fe1API\u304c\u7a4d\u3093\u3067\u3042\u308b\u3093\u3060\u304c\u3001\u4f55\u6545\u304bGUI\u306e\u304f\u305b\u306b\u30b3\u30de\u30f3\u30c9\u304b\u3089IP\u7b49\u306e\u8a2d\u5b9a\u3092\u3057\u306a\u3044\u3068\u901a\u4fe1\u6a5f\u80fd\u304c\u4f7f\u3048\u306a\u3044\u3068\u3044\u3046\u8b0e\u4ed5\u69d8\u3067\u3042\u308b\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306fLua\u30b9\u30af\u30ea\u30d7\u30c8\u3067<\/p>\n<pre><code class=\"\">comm.socketServerSend(\"fuck the police\")\n<\/code><\/pre>\n<p>\u3068\u304b\u3084\u3063\u3066\u3082\u3001<\/p>\n<pre><code class=\"\">Socket server was not initialized, please initialize it via the command line\n-1\n<\/code><\/pre>\n<p>\u3068\u6012\u3089\u308c\u308b\u3002<br \/>\n\u521d\u671f\u5316\u3055\u308c\u3066\u306a\u3044\u306a\u3089\u521d\u671f\u5316\u3059\u308c\u3070\u3048\u3048\u3084\u3093\u3068\u601d\u3046\u3093\u3060\u304c\u3001\u521d\u671f\u5316\u3059\u308b\u95a2\u6570\u306d\u30fc\u3093\u3060\u3053\u308c\u304c\u3002<br \/>\n\u3067\u3001\u30bd\u30fc\u30b9\u898b\u305f\u3089\u300c\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067ip\u3068port\u3092\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u306e\u307f\u521d\u671f\u5316\u3059\u308b\u300d\u3068\u3044\u3046\u4ed5\u69d8\u3060\u3063\u305f\u3002\u306a\u3093\u3067\u3084\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001BizHawk\u8d77\u52d5\u306f\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3092\u4ecb\u3057\u3066\u884c\u3046\u3002<br \/>\nBizHawk.exe\u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306brun.bat\u3042\u305f\u308a\u306e\u540d\u524d\u3067\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u3044\u3002\u5185\u5bb9\u306f\u4ee5\u4e0b\u3002<\/p>\n<pre><code class=\"\">@echo off\nEmuHawk --socket_ip=127.0.0.1 --socket_port=22222\nexit\n<\/code><\/pre>\n<p>\u305f\u3060\u3057\u8d77\u52d5\u6642\u306b\u5373\u30b5\u30fc\u30d0\u30fc\u3078\u63a5\u7d9a\u3092\u8a66\u307f\u305f\u6319\u3052\u53e5\u3001\u5931\u6557\u3059\u308b\u3068\u305d\u308c\u3063\u304d\u308a\u306a\u306e\u3067\u3001\u307e\u305a\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3066\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<h2>\u30b5\u30fc\u30d0\u30fc\u3092\u305f\u3066\u308b<\/h2>\n<p>\u4eca\u56de\u306fC#\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u4f8b\u3092\u793a\u3059\u3002<\/p>\n<pre><code class=\"language-csharp \">using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Net;\nusing System.Net.Sockets;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace SocketServer\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            TcpListener tcp;\n            const int PORT = 22222;\n            IPAddress IP = IPAddress.Parse(\"127.0.0.1\");\n\n            \/\/127.0.0.1\u306b22222\u306e\u30bd\u30b1\u30c3\u30c8\u30b5\u30fc\u30d0\u3092\u5efa\u3066\u308b\n            tcp = new TcpListener(IP, PORT);\n\n            \/\/\u53d7\u4ed8\u958b\u59cb\n            Console.Write(\"Waiting for a connection... \");\n            tcp.Start();\n            var cli = tcp.AcceptTcpClient();\n            Console.WriteLine(\"Connected!\");\n\n            \/\/\u8aad\u307f\u8fbc\u307f\u30eb\u30fc\u30d7\n            var nstr = cli.GetStream();\n            try\n            {\n                while (cli.Connected)\n                {\n                    byte[] buf = new byte[1024];\n                    var cnt = nstr.Read(buf, 0, 1024);\n                    var str = Encoding.UTF8.GetString(buf, 0, cnt);\n\n                    Console.WriteLine(str);\n                }\n            }\n            catch (Exception ex)\n            {\n                \/\/\u30a8\u30df\u30e5\u3092\u7d42\u4e86\u3055\u305b\u308b\u3068\u4f8b\u5916\u306b\u306a\u3063\u305f\u308a\u3059\u308b\u306e\u3067\u898b\u306a\u304b\u3063\u305f\u3053\u3068\u306b\u3059\u308b\n            }\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3057\u305f\u72b6\u614b\u3067\u6539\u3081\u3066comm.socketServerSend(str)\u3059\u308c\u3070\u9001\u3063\u305f\u6587\u5b57\u5217\u304c\u305d\u306e\u307e\u307e\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u3066\u304f\u308b\u305e\u3002<br \/>\n\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092\u4fdd\u3063\u305f\u72b6\u614b\u3067\u30b9\u30c8\u30ea\u30fc\u30e0\u306b\u5782\u308c\u6d41\u3059\u611f\u3058\u306a\u306e\u3067\u3001\u3042\u3068\u306f\u3060\u3089\u3060\u3089\u30b9\u30c8\u30ea\u30fc\u30e0\u3092\u30eb\u30fc\u30d7\u304b\u3089\u8aad\u3081\u3070\u3044\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u308a\u305f\u3044\u3053\u3068 \u7d71\u5408\u30a8\u30df\u30e5\u3067\u3042\u308bBizHawk\u304b\u3089\u3001Lua\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4ecb\u3057\u3066Soc &hellip; <a href=\"https:\/\/drroot.page\/wp\/?p=55\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=55"}],"version-history":[{"count":5,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}