title: Can't connect using setsockopt in python
body: <p>I am new to python. So the question seems silly.</p>
  
  <p>I want to implement a simple program for client and server in python.</p>
  
  <p>The server.py is</p>
  
  <pre><code>import socket
  #s = socket.socket()
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.setsockopt(socket.SOL_SOCKET, 25, "wlan0"+'\0')
  host = socket.gethostname()
  port = 12345
  s.bind((host,port))
  s.listen(5)
  while True:
      c,addr = s.accept()
      print "Got connection from",addr
      c.send("Thank you for connecting")
      c.close()
  </code></pre>
  
  <p>The client.py is</p>
  
  <pre><code>import socket
  #s = socket.socket()
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.setsockopt(socket.SOL_SOCKET, 25, "wlan0"+'\0')
  host = socket.gethostname()
  port = 12345
  s.connect((host,port))
  print s.recv(1024)
  s.close
  </code></pre>
  
  <p>The problem is that compiler is showing an error "operation is not permitted". I tried executing program as root. The error is gone, But client and server connection was not made.</p>
  
  <p>Everything works fine before adding this line</p>
  
  <pre><code>   s.setsockopt(socket.SOL_SOCKET, 25, "wlan0"+'\0')
  </code></pre>
  
  <p>Hope somebody can aswer my problem.
  I want to connect client and server through wlan0 interface.</p>
  
  <p>Thanks.</p>