Created
June 10, 2014 23:57
-
-
Save skinkie/753d1eb878bae75ac577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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