title: Why is there TCP RST packet after sending a string and closing a socket
body: <p>I try to use python socket to send char Y and after enter But when I capture wireshark i detect it error. Why?
  The code in python:</p>
  
  <pre><code>import socket
  import re
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  server_address = (('pwnable.kr', 9009))
  sock.connect((server_address))
  b=sock.recv(2048)    # I must use 2 sock.recv then recv full text 
  print b
  b=sock.recv(2048)
  print b
  b=re.findall("Y/N",b)
  print b
  #sock.recv(1024)
  if b[0]=="Y/N":
      print "OK"
      sock.send(("Y"+"\r\n").encode())
      b=sock.recv(1024)
  </code></pre>
  
  <p>Wireshark capture:
  <a href="https://i.stack.imgur.com/lv0u7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lv0u7.png" alt="enter image description here"></a>
  How to send string and then enter?
  Using multiple sock.recv affect anything?</p>
  
  <hr>
  
  <p>UPDATE1:
  I want print last b, it should is </p>
  
  <pre><code>Enter 1 to Begin the Greatest Game Ever Played.
  Enter 2 to See a Complete Listing of Rules.
  Enter 3 to Exit Game. (Not Recommended)
  Choice: 
  </code></pre>
  
  <p>But i receive null list. 
  My code:</p>
  
  <pre><code>import socket
  import re
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)   
  server_address = (('pwnable.kr', 9009))  
  sock.connect((server_address))
  b=sock.recv(2048)
  print b
  b=sock.recv(2048)
  print b
  b=re.findall("Y/N",b)
  print b
  #sock.recv(1024)
  if b[0]=="Y/N":
      print "OK"
      sock.send(("Y"+"\r\n").encode())
      b=sock.recv(1024)
      print b
  sock.close()    
  </code></pre>
  
  <p>In wireshark have red line:
  <a href="https://i.stack.imgur.com/KlSPm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KlSPm.png" alt="enter image description here"></a></p>