Just starting out? Need help? Post your questions and find answers here.
-
chris319
- Enthusiast
- Posts: 782
- Joined: Mon Oct 24, 2005 1:05 pm
Post
by chris319 »
I'm trying to write a program to read and play an icecast audio stream and this is as far as I've gotten:
The program appears to make the network connection but it is not reading any data from the stream on port 8000.
Code: Select all
*buffer = AllocateMemory(16384)
connectionID = OpenNetworkConnection("localhost",8000)
If connectionID <> 0: Debug "connected": Else: Debug "no connection" :EndIf
While NetworkClientEvent(connectionID) = 0
Wend
event = NetworkClientEvent(connectionID)
If event <> 0
Debug "event"
EndIf
result = ReceiveNetworkData(connectionID, *buffer, 16)
Debug result
FreeMemory (*buffer, 16384)
How to make this work?
-
infratec
- Always Here
- Posts: 6883
- Joined: Sun Sep 07, 2008 12:45 pm
- Location: Germany
Post
by infratec »
As far as I know, streams using normally udp and not tcp.
-
chris319
- Enthusiast
- Posts: 782
- Joined: Mon Oct 24, 2005 1:05 pm
Post
by chris319 »
So you need something to start any action.
You need a http get request to the stream you want to listen to.
See the code I posted. It connects but that's all.
-
infratec
- Always Here
- Posts: 6883
- Joined: Sun Sep 07, 2008 12:45 pm
- Location: Germany
Post
by infratec »
I see only that you open a connection, but nothing else.
So what should the server do???
Should he immediately 'stream' every music he has stored?
He thinks: Oh nice, a new connection. I'm waiting now for a message what is expected from me.
You have to start a stream via a http get request.
(As I can read from the link which I wrote above.)
-
chris319
- Enthusiast
- Posts: 782
- Joined: Mon Oct 24, 2005 1:05 pm
Post
by chris319 »
You have to start a stream via a http get request.
How to do this in PB?
-
infratec
- Always Here
- Posts: 6883
- Joined: Sun Sep 07, 2008 12:45 pm
- Location: Germany
Post
by infratec »
You should learn the basics of some protocols
Something like:
Code: Select all
Request$ = "GET /YourMountPointOfTheStreamYouWant HTTP/1.1" + #CRLF$
;Request$ + "Accept: audio/mp3" + #CRLF$
Request$ + "Content-Length: 0" + #CRLF$
Request$ + #CRLF$
SendNetworkString(connectionID, Request$)