在 iOS 上打开与 Icecast 服务器的套接字连接 [英] Open socket connection with Icecast server on iOS

查看:45
本文介绍了在 iOS 上打开与 Icecast 服务器的套接字连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 iOS 上的 Icecast 服务器创建源客户端.

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

我相信我理解这里的协议 Icecast 2:协议描述,使用 C# 流式传输

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

但是,我无法创建到服务器的套接字连接.假设服务器在 http://myicecastserver.com 的 8000 端口上运行.我设置了一个名为 stream 的挂载点,它在 ezstream 用作输入时起作用.我应该如何从 iOS 打开连接?

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?

我已经像这样使用了 AsyncSocket 库:

I have used the AsyncSocket library like this:

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

像这样:

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

无济于事.

我也尝试使用带有 SocketRocket 的 websocket 连接也无济于事:

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];

这给了我一个 404 错误

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!

更新

我使用 SocketTest 作为测试源客户端,并且能够连接到 http://myicecastserver.com8000端口

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

推荐答案

我的解决方案如下:

我正在像这样使用 AsyncSocket 库:

I am using the AsyncSocket library like this:

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

诀窍是删除http://"(是的,我就是这么傻)然后在连接时我可以发送正确的标头.

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

这篇关于在 iOS 上打开与 Icecast 服务器的套接字连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆