{"action":"opened","issue":{"url":"https://api.github.com/repos/nanomsg/nanomsg/issues/796","repository_url":"https://api.github.com/repos/nanomsg/nanomsg","labels_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/796/labels{/name}","comments_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/796/comments","events_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/796/events","html_url":"https://github.com/nanomsg/nanomsg/issues/796","id":172220191,"number":796,"title":"Windows: Can bind socket on IP not used by machine. ","user":{"login":"mascojames","id":1402708,"avatar_url":"https://avatars.githubusercontent.com/u/1402708?v=3","gravatar_id":"","url":"https://api.github.com/users/mascojames","html_url":"https://github.com/mascojames","followers_url":"https://api.github.com/users/mascojames/followers","following_url":"https://api.github.com/users/mascojames/following{/other_user}","gists_url":"https://api.github.com/users/mascojames/gists{/gist_id}","starred_url":"https://api.github.com/users/mascojames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mascojames/subscriptions","organizations_url":"https://api.github.com/users/mascojames/orgs","repos_url":"https://api.github.com/users/mascojames/repos","events_url":"https://api.github.com/users/mascojames/events{/privacy}","received_events_url":"https://api.github.com/users/mascojames/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-19T21:04:09Z","updated_at":"2016-08-19T21:04:09Z","closed_at":null,"body":"Nanomsg on Windows allows for binding on IP address not belonging to the current machine. A failure does not occur til further in the process. This does not occur on Linux, Linux fails at binding the socket, Windows should behave similarly.\r\n\r\nHere's a small easily repeatable test case (In C++11):\r\n```\r\n   int outgoing_socket = nn_socket (AF_SP, NN_PUB);\r\n\r\n   if (outgoing_socket < 0)\r\n   {\r\n      std::cout << \"Failed to create socket: \" << nn_strerror(nn_errno()) << std::endl;\r\n   }\r\n   else\r\n   {\r\n      std::string topic = \"tcp://123.45.67.89:12345\";\r\n      std::this_thread::sleep_for(std::chrono::milliseconds(100));\r\n      int endpoint_id = nn_bind (outgoing_socket, topic.c_str());\r\n      if(endpoint_id < 0)\r\n      {\r\n         std::cout << \"Failed to bind socket: \" << nn_strerror(nn_errno()) << std::endl ;\r\n      }\r\n      else\r\n      {\r\n         std::cout << \"Connected to: \" << topic << std::endl;\r\n         char buff[10] = {0};\r\n         std::this_thread::sleep_for(std::chrono::milliseconds(100));\r\n         int bytes_sent = nn_send(outgoing_socket, buff, 10, 0);\r\n         if (bytes_sent == 10)\r\n         {\r\n            std::cout << \"Successfully sent 10 bytes\" << std::endl;\r\n         }\r\n         else\r\n         {\r\n            std::cout << \"Failed to send bytes\" << std::endl;\r\n         }\r\n         std::this_thread::sleep_for(std::chrono::milliseconds(100));\r\n         nn_shutdown(outgoing_socket, endpoint_id);\r\n\r\n         std::cout << \"Shutdown Complete.\";\r\n      }\r\n      std::this_thread::sleep_for(std::chrono::milliseconds(100));\r\n      nn_close(outgoing_socket);\r\n      std::cout << \"Close Complete.\";\r\n   }\r\n```\r\n\r\nOutput is:\r\n````\r\n1>  Connected to: tcp://123.45.67.89:12345\r\n1>  Successfully sent 10 bytes\r\n1>  Assertion failed: 3 == NN_TIMER_STATE_IDLE (..\\..\\src\\aio\\timer.c:62)\r\n````"}}
{"actor":{"display_login":"mascojames"}}