title: Python3:socket:TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes'
body: <p>I am try to use python <code>socket</code> package to implement an echo  server. But it continuously occurs the error: <code>TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes'</code>, is there any errors in my code? </p>
  
  <p>here is the error:</p>
  
  <pre><code>Exception in thread Thread-1:
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py", line 921, in _bootstrap_inner
          self.run()
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py", line 869, in run
          self._target(*self._args, **self._kwargs)
    File "do_tcp_server.py", line 25, in tcplink
          sock.send(b'Hello, %s!' % data)
  TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes'
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p>server.py:</p>
  
  <pre><code>#!/usr/bin/env python3
  # coding: utf-8
  
  "A simple server"
  
  import socket
  import threading
  import time
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  s.bind(("127.0.0.1", 9999))
  
  s.listen(5)
  print("Lsitening...")
  
  def tcplink(sock, addr):
      print('Accept new connection from %s:%s...' % addr)
      sock.send(b'Welcome!')
      while True:
          data = sock.recv(1024)
          time.sleep(1)
          if not data or data.decode('utf-8') == 'exit':
              break
          sock.send(b'Hello, %s!' % data)
      sock.close()
      print('Connection from %s:%s closed.' % addr)
  
  while True:
      sock, addr = s.accept()
      # create a thread to handle it
      t = threading.Thread(target=tcplink, args=(sock, addr))
      t.start()
  </code></pre>
  
  <p>client.py:</p>
  
  <pre><code>#!/usr/bin/env python3
  # coding: utf-8
  
  import socket
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  # establish connection:
  s.connect(('127.0.0.1', 9999))
  # receive Welcome data:
  print(s.recv(1024).decode('utf-8'))
  for data in [b'Michael', b'Tracy', b'Sarah']:
      # send data
      s.send(data)
      print(s.recv(1024).decode('utf-8'))
  s.send(b'exit')
  s.close()
  </code></pre>