Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以在服务器上没有专用端口的情况下运行socketio swift吗_Swift_Socket.io - Fatal编程技术网

我可以在服务器上没有专用端口的情况下运行socketio swift吗

我可以在服务器上没有专用端口的情况下运行socketio swift吗,swift,socket.io,Swift,Socket.io,我使用这个简单的SocketIOManager类来连接服务器 static let sharedInstance = SocketIOManager() let manager = SocketManager(socketURL: URL(string: "http://192.168.31.57:3000")!, config: [.log(true), .compress]) override init() { super.init() } func establishConn

我使用这个简单的SocketIOManager类来连接服务器

static let sharedInstance = SocketIOManager()

let manager = SocketManager(socketURL: URL(string: "http://192.168.31.57:3000")!, config: [.log(true), .compress])

override init() {
    super.init()
}

func establishConnection() {
    manager.defaultSocket.connect()
}


func closeConnection() {
    manager.defaultSocket.disconnect()
}

这里的IP是我的本地主机IP,我正在监听的端口是在我从internet下载的node.js文件中定义的。其工作良好,并按预期连接。然而,在我的实际项目中,我试图连接到out服务器,我的api团队没有给我任何特定的端口来监听,他们只是给了我url。不用说,我无法与服务器建立套接字连接。我的问题是,我可以在不监听特定端口的情况下建立套接字连接吗?这是我的第一个socket编程项目,我在互联网上发现很少有关于iOS中socket编程的教程。我正在使用socket.io-client-swift库。

在socket基本连接中,端口是非常需要的

套接字是网络上运行的两个程序之间双向通信链路的一个端点。套接字绑定到端口号,以便TCP层可以识别数据要发送到的应用程序