#standart lib
import socket           


#enter 'hciconfig' command in linux to find out the address
hostMACAddress = '#device bluetooth address'        

port = 1234
backlog = 1
size = 1024
#defining socket
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
#binding socket
s.bind((hostMACAddress,port))
#prepare the server
s.listen(blacklog)

#send data
try:
    client, address = s.accept()
    while 1:
        data = client.recv(size)
        if data:
            print(data)
            client.send(data)
except:	
    print("Closing socket")	
    client.close()
    s.close()

