I want create a server for download file audio from other pc/smartphone, this is the code
TCPStartup()
global $MainSocket = TCPListen(@IPAddress1, 555)
While 1
Do
$ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket > 0
$err = 0
Do
$msg = TCPRecv($ConnectedSocket,1024)
$err = @error
If StringLen($msg) THEN
$file = FileOpen("Gettin_Over_You.mp3", 0)
$FileContent = FileRead($file)
FileClose($file)
TCPSend($connectedSocket, Binary("HTTP/1.1 200 OK" & @CRLF & "Access-Control-Allow-Origin: *" & @CRLF))
TCPSend($connectedSocket, Binary("Content-Length: " & FileGetSize("Gettin_Over_You.mp3") & @CRLF))
TCPSend($connectedSocket, Binary("Content-Type: audio/mpeg" & @CRLF & @CRLF & $FileContent))
sleep(10)
TCPCloseSocket($ConnectedSocket)
endIf
Until $err
WEnd
the problem is that when i load page, the song starts but i don't see the duration and on the screen appears "streaming"
can you help me?
TCPStartup()
global $MainSocket = TCPListen(@IPAddress1, 555)
While 1
Do
$ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket > 0
$err = 0
Do
$msg = TCPRecv($ConnectedSocket,1024)
$err = @error
If StringLen($msg) THEN
$file = FileOpen("Gettin_Over_You.mp3", 0)
$FileContent = FileRead($file)
FileClose($file)
TCPSend($connectedSocket, Binary("HTTP/1.1 200 OK" & @CRLF & "Access-Control-Allow-Origin: *" & @CRLF))
TCPSend($connectedSocket, Binary("Content-Length: " & FileGetSize("Gettin_Over_You.mp3") & @CRLF))
TCPSend($connectedSocket, Binary("Content-Type: audio/mpeg" & @CRLF & @CRLF & $FileContent))
sleep(10)
TCPCloseSocket($ConnectedSocket)
endIf
Until $err
WEnd
the problem is that when i load page, the song starts but i don't see the duration and on the screen appears "streaming"
can you help me?