Jump to content

UDPSend


Recommended Posts

Is it possible to send an mp3-file via udp?

this is the code we got now:

UDPStartup()

$socket = UDPOpen("127.0.0.1", 65532)

While 1
    $file = FileOpen("01 - Korn - Twist.mp3", 0)
    $read = FileRead($file)
    UDPSend($socket, String($read))
    FileClose($file)
    If Not @error then 
        Exit
    EndIf
WEnd

;;This is the UDP Server
;;Start this first

; Start The UDP Services
;==============================================
UDPStartup()

; Bind to a SOCKET
;==============================================
$socket = UDPBind("127.0.0.1", 65532)
If @error <> 0 Then Exit

While 1
    $data = UDPRecv($socket, 50)
    Hex($data)
    If $data <> "" Then
        MsgBox(0, "UDP DATA", $data)
        $write = FileOpen("Incoming/test.mp3", 2)
        FileWrite($write, $data)
        FileClose($write)
        
        UDPCloseSocket($socket)
        UDPShutdown()
        Exit
    EndIf
    sleep(100)
WEnd
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...