{"id":5547,"date":"2016-07-19T19:24:10","date_gmt":"2016-07-20T00:24:10","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=5547"},"modified":"2016-07-19T20:01:34","modified_gmt":"2016-07-20T01:01:34","slug":"connection-reset-what-does-it-mean","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2016\/07\/19\/connection-reset-what-does-it-mean\/","title":{"rendered":"Connection Reset &#8211; What does it mean?"},"content":{"rendered":"<p>Generally, it indicates your client successfully connected to the server.  A subsequent attempt to use the client connection failed after the server closed the socket, or had been disconnected for any reason.<\/p>\n<p>You can prove this with what is below, after starting the serverSocket in another window&#8230;<\/p>\n<pre>\r\nc:\\Users\\showard>type serverSocket.java\r\nimport java.net.*;\r\nimport java.io.*;\r\n\r\nclass serverSocket {\r\n  public static void main (String args[]) throws Exception {\r\n    ServerSocket ss;\r\n    ss = new ServerSocket(5000);\r\n    Socket clientSocket = ss.accept();\r\n    Thread.sleep(20000);\r\n  }\r\n}\r\n\r\nclass clientSocket {\r\n  public static void main (String args[]) throws Exception {\r\n    Socket s = new Socket(\"localhost\", 5000);\r\n    DataInputStream input = null;\r\n    try {\r\n      input = new DataInputStream(s.getInputStream());\r\n    }\r\n    catch (Exception e) {\r\n      e.printStackTrace();\r\n    }\r\n    Thread.sleep(10000);\r\n    byte[] b = new byte[input.readInt()];\r\n  }\r\n}\r\n\r\nc:\\Users\\showard>java clientSocket\r\nException in thread \"main\" java.net.SocketException: Connection reset\r\n        at java.net.SocketInputStream.read(Unknown Source)\r\n        at java.net.SocketInputStream.read(Unknown Source)\r\n        at java.net.SocketInputStream.read(Unknown Source)\r\n        at java.io.DataInputStream.readInt(Unknown Source)\r\n        at clientSocket.main(serverSocket.java:24)\r\n\r\nc:\\Users\\showard>cd c:\\Users\\showard\r\n<\/pre>\n<p>It should be noted that this depends on the OS on which the JVM runs.  For example, the code above will throw a java.io.EOFException.  It all depends on what exception the OS hands back to the JVM, which then translates it.  On Linux, the recvfrom() system call on the socket with no one on the other end resulted in the following:<\/p>\n<pre>\r\nrecvfrom(6, \"\", 1, 0, NULL, NULL) = 0\r\n<\/pre>\n<p>a &#8220;man recvfrom&#8221; will show the following..<\/p>\n<pre>\r\nssize_t recvfrom(int s, void *buf, size_t len, int flags,\r\n                        struct sockaddr *from, socklen_t *fromlen);\r\n<\/pre>\n<p>As such, our failed call used file descriptor 6, had a zero length buffer, the size was 1, flags were 0, and the from socket address and from length were each null.  The value of 0 for the recvfrom() return value indicates the peer had an orderly shutdown, which it did.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generally, it indicates your client successfully connected to the server. A subsequent attempt to use the client connection failed after the server closed the socket, or had been disconnected for any reason. You can prove this with what is below,&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2016\/07\/19\/connection-reset-what-does-it-mean\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[25,56],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5547"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5547"}],"version-history":[{"count":4,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5547\/revisions"}],"predecessor-version":[{"id":5552,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5547\/revisions\/5552"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5547"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}