title: Python socket programming and LED interfacing
body: <p>I'm trying to write socket programming in python. Whenever client sends message to server, LED should start blinking.
  I'm running server program on Raspberry pi and client on PC.</p>
  
  <p>Here is the code of server which is running on my Pi.</p>
  
  <pre><code>#!/usr/bin/python             # This is server.py file
  import socket                 # Import socket module
  import time
  import RPi.GPIO as GPIO       # Import GPIO library
  GPIO.setmode(GPIO.BOARD)      # Use board pin numbering
  GPIO.setup(11, GPIO.OUT)      # Setup GPIO Pin 11 to OUT
  GPIO.output(11,False)         # Init Led off
  
  def led_blink():
      while 1:
          print "got msg"         # Debug msg
          GPIO.output(11,True)    # Turn on Led
          time.sleep(1)           # Wait for one second
          GPIO.output(11,False)   # Turn off Led
          time.sleep(1)           # Wait for one second
      GPIO.cleanup()
  
  s = socket.socket()           # Create a socket object
  host = "192.168.0.106"        # Get local machine name
  port = 12345                  # Port
  s.bind((host, port))          # Bind to the port
  s.listen(5)                   # Now wait for client connection.
  while True:
      c, addr = s.accept()       # Establish connection with client.
      print 'Got connection from', addr
      msg = c.recv(1024)
      msg1 = 10
      if msg == msg1:
          led_blink()
      print msg
      c.close()
  </code></pre>
  
  <p>Here is the code of client which is running on my PC.</p>
  
  <pre><code>#!/usr/bin/python           # This is client.py file
  import socket               # Import socket module
  s = socket.socket()         # Create a socket object
  host = "192.168.0.106" # Get local machine name
  port = 12345                # port
  
  s.connect((host, port))
  s.send('10')
  s.close  
  </code></pre>
  
  <p>I'm able to receive the message from client, But not able to blink the LED.
  Sorry I'm new to coding. I've pretty good knowledge in hardware but not in software.
  Please help me.</p>