我正在开发一些不需要在App Store上的东西,所以我没有使用私有API来满足我的需求的问题我正在尝试使用MobileWiFi. framework to read the RSSI value for the wireless network the phone is currently connected to. I've included thehttps://github.com/Cykey/ios-reversed -headers/tree/c613e45f3ee5ad9f85ec7d43906cf69ee812ec6a/MobileWiFi`标题并使用桥接头将它们包含在我的swift项目中并编写如下代码.请原谅,我是新手.
import SystemConfiguration.CaptiveNetwork
typealias _WiFiManagerClientCreate = @convention(c) (CFAllocator, CInt) -> UnsafeRawPointer
typealias _WiFiManagerClientCopyDevices = @convention(c) (UnsafeRawPointer) -> CFArray
typealias _WiFiDeviceClientCopyProperty = @convention(c) (UnsafeRawPointer, CFString) -> CFPropertyList
if let libHandle = dlopen (Paths.ipConfiguration, RTLD_LAZY) {
result = libHandle.debugDescription
let _createManagerPtr = dlsym(libHandle, "WiFiManagerClientCreate")
let _clientCopyDevicesPtr = dlsym(libHandle, "WiFiManagerClientCopyDevices")
let _clientCopyPropertyPtr = dlsym(libHandle, "WiFiDeviceClientCopyProperty")
if (_createManagerPtr != nil) …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到在 Amazon EC2 服务器上运行的 postgres 数据库。我知道服务器配置正确,因为我可以从 pgadmin 访问它并作为 intellij 中的数据源。
当仅使用 jsch 时,我还可以从程序中连接到服务器 shell,并直接使用 jdbc 连接到另一个数据库,但是一旦我尝试通过 ssh 隧道与 jsch 连接到我的 postgres 实例,我就会遇到这个奇怪的错误无法诊断:
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:262)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:67)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:216)
at org.postgresql.Driver.makeConnection(Driver.java:406)
at org.postgresql.Driver.connect(Driver.java:274)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at EnumStreamer.main(EnumStreamer.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.io.EOFException
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:285)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:411)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:208)
... 12 more
Run Code Online (Sandbox Code Playgroud)
我用来连接的代码如下:
System.out.println("Connecting...");
session = secConnect.getSesssion();
UserInfo ui = new uInfo();
session.setUserInfo(ui);
session.connect();
session.setPortForwardingL(5432,secConnect.getHost(),5432);
System.out.println("SSH …Run Code Online (Sandbox Code Playgroud)