Skip to content

Instantly share code, notes, and snippets.

@skinkie
Created June 10, 2014 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skinkie/753d1eb878bae75ac577 to your computer and use it in GitHub Desktop.
Save skinkie/753d1eb878bae75ac577 to your computer and use it in GitHub Desktop.
#!/usr/bin/python # This is server.py file
import socket # Import socket module
s = socket.socket() # Create a socket object
host = "192.168.0.5" # Get local machine name
port = 56778 # Reserve a port for your service.
s.bind((host, port)) # Bind to the port
s.listen(5) # Now wait for client connection.
MSG_REC = "FREE_RECORDER REC"
FILENAME = "FILENAME:"
f = open('out.wav', 'w')
while True:
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
print c.recv(1024)
print c.recv(1024)
c.send(MSG_REC + "\r\n" + FILENAME + "rec.wav" + "\r\n")
print c.recv(1460)
while True:
data = c.recv(1460)
f.write(data)
print len(data)
c.close() # Close the connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment