title: Python Socket Program - NameError: name 'self' is not defined. I changed the localhost, ports etc but this error refuses to go away
body: <pre><code>import socket
  
  MAX_BUFFER_SIZE = 4096
  
  class ClientSocket:
  
      def __init__(self):
          print("Client socket started....")
          self.soc = None
  
      def send_to_Server(self, data):
          print('Time to send data to Server..... %s', data)
          self.soc.send(data.encode("utf8"))   
  
      def receive_from_Server(self):
          print('Time to receive from Server.....')
          result_bytes = self.soc.recv(MAX_BUFFER_SIZE)
          result_string = result_bytes.decode("utf8")
          print("Result from server is {}".format(result_string))
  
      def start_client(self):
          self.soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.soc.connect(("localhost", 8000))
          print('Client connected....')
  </code></pre>
  
  <p>husainshoab@hs-Len:~$ python IOTDeviceSocket.py</p>
  
  <p>Traceback (most recent call last):
    File "IOTDeviceSocket.py", line 7, in 
      class ClientSocket:
    File "IOTDeviceSocket.py", line 11, in ClientSocket
      self.soc = None
  NameError: name 'self' is not defined</p>