title: Having issue with pyaudio and sockets
body: <p>I am trying to fix a script I wrote. It's a client application and I need to figure out how to use sockets to record data from a computer running linux in my office.</p>
  
  <p>I am using netcat for the server, listening on port 5555.</p>
  
  <p>I know I have to convert the <code>i</code> to a integer, but am having trouble.</p>
  
  <p>I already have a ftp script for sending the .wav file I just need to get the <code>s.recv</code> prompt to work.</p>
  
  <pre><code>import pyaudio
  import wave
  from socket import*
  s = socket()
  host = "127.0.0.1"
  port = 5555
  s.connect((host,port))
  s.send("how many seconds?\n")
  i = s.recv(2)
  CHUNK = 1024 
  FORMAT = pyaudio.paInt16 #paInt8
  CHANNELS = 2 
  RATE = 44100 #sample rate
  RECORD_SECONDS = i
  WAVE_OUTPUT_FILENAME = "output.wav"
  
  p = pyaudio.PyAudio()
  
  stream = p.open(format=FORMAT,
              channels=CHANNELS,
              rate=RATE,
              input=True,
              frames_per_buffer=CHUNK) #buffer
  
  print("* recording")
  
  frames = []
  
  for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    frames.append(data) # 2 bytes(16 bits) per channel
  
  print("* done recording")
  
  stream.stop_stream()
  stream.close()
  p.terminate()
  
  wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
  wf.setnchannels(CHANNELS)
  wf.setsampwidth(p.get_sample_size(FORMAT))
  wf.setframerate(RATE)
  wf.writeframes(b''.join(frames))
  wf.close()
  </code></pre>