title: How to open a Port on Server
body: <p>I am new to opening a port and server side programming. And I am trying to open a port on my server in python and then form an iOS app get some data from that port. I have done some research and know I can open a port like this</p>
  
  <pre><code>import socket               # Import socket module
  
  s = socket.socket()         # Create a socket object
  host = socket.gethostname() # Get local machine name
  port = 12345                # Reserve a port for your service.
  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
     c.send('Thank you for connecting')
     c.close()                # Close the connection
  </code></pre>
  
  <p>But my question is lets say I just wanted to retrieve a simple string from this port how do I add that string to this open port, I have found some ways to get data from the port in iOS like this library <a href="https://github.com/armadsen/ORSSerialPort" rel="nofollow">https://github.com/armadsen/ORSSerialPort</a> but how do I put the data like a string on the open port?</p>
  
  <p>Thanks for the help in advance.</p>