Skip to content

Instantly share code, notes, and snippets.

@rahulrkroy
Created March 25, 2018 09:08
Show Gist options
  • Select an option

  • Save rahulrkroy/0ad6aeff9b10b6f91a9c11ba505315f2 to your computer and use it in GitHub Desktop.

Select an option

Save rahulrkroy/0ad6aeff9b10b6f91a9c11ba505315f2 to your computer and use it in GitHub Desktop.

Revisions

  1. rahulrkroy created this gist Mar 25, 2018.
    30 changes: 30 additions & 0 deletions data_transfer_on_python_using_udp.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/usr/bin/python2
    import socket,time,os,commands

    print "we are doing UDP socket programming"

    x= socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
    # above line means we are using ipv4,on UDP protocol
    # belo lines only for receiver
    '''
    x.bind(("10.10.5.236",7777)) #7777 is port no,first one is receivers ip
    '''
    #for sender
    x.sendto("Its Working",("10.10.5.239",7777))
    data= x.recvfrom(100)
    print data[0]
    sound = "echo "+str(data[0])+" | festival --tts"
    os.system(sound)

    #for reciver only
    '''while 3>2:
    data= print x.recvfrom(100) #100 is maximum no of msg receive
    print data[0]
    print data[1]
    time.sleep(2)
    sound = "echo "+str(data[0])+" | festival --tts"
    os.system(sound)
    '''