Open socket connection with Icecast server on iOS

我是研究僧i 提交于 2019-12-08 08:56:58

问题


I am trying to create a source client for an Icecast server on iOS.

I believe I understand the protocol here Icecast 2: protocol description, streaming to it using C#

However, I am having trouble creating the socket connection to the server. Say the server is running on port 8000 at http://myicecastserver.com. I setup a mountpoint called stream which works when ezstream is used as input. How should I open the connection from iOS?

I have used the AsyncSocket library like this:

[socket connectToHost:@"http://myicecastserver.com" onPort:8000 error:&err];

like this:

[socket connectToHost:@"http://myicecastserver.com/stream" onPort:8000 error:&err];

to no avail.

I also tried using a websocket connection with SocketRocket also to no avail:

SRWebSocket *socket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:@"http://myicecastserver.com:8000/stream"]];
[socket setDelegate:self];
[socket open];

this gives me a 404 error

I have tried a few variations on this but just cannot open this connection to save my life! Thanks!

UPDATE

I am using SocketTest as a test source client and am able to connect to http://myicecastserver.com on port 8000


回答1:


My solution is as follows:

I am using the AsyncSocket library like this:

[socket connectToHost:@"myicecastserver.com" onPort:8000 error:&err];

the trick was to remove 'http://' (yes, I am that silly) then on connect I can send the right headers.



来源:https://stackoverflow.com/questions/13203154/open-socket-connection-with-icecast-server-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!