需要一次(http://localhost:8080/javabridge/java/java.inc):未能打开流:http请求失败!在/library/webserver/documents/test.php中

92dk7w1h  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(199)

我试着用下面的代码连接我的php和java应用程序

<?php 
    echo "Connecting...\r\n";
    require_once("http://localhost:8080/JavaBridge/java/Java.inc");
?>

但当我想连接时,我遇到了这样的错误

Connecting...
Warning: require_once(http://localhost:8080/JavaBridge/java/Java.inc): failed to open stream: HTTP request failed! in /Library/WebServer/Documents/test.php on line 3

Fatal error: require_once(): Failed opening required 'http://localhost:8080/JavaBridge/java/Java.inc' (include_path='.:') in /Library/WebServer/Documents/test.php on line 3

我尝试打开used localhost&127.0.0.1 allowed\u url\u include=on
我在tcp套接字中的php java桥中设置为仅使用端口8080
使用此代码

// 
// Decompiled by Procyon v0.5.36
// 

package php.java.bridge.http;

import java.net.Socket;
import java.net.UnknownHostException;
import java.net.InetAddress;
import java.io.IOException;
import java.net.ServerSocket;

public class TCPServerSocket implements ISocketFactory
{
    public static int TCP_PORT_BASE;
    private ServerSocket sock;
    private int port;
    boolean local;

    public static ISocketFactory create(String name, final int backlog) throws IOException {
        boolean local = false;
        if (name == null) {
            throw new NullPointerException("name");
        }
        if (name.startsWith("INET:")) {
            name = name.substring(5);
        }
        else if (name.startsWith("INET_LOCAL:")) {
            local = true;
            name = name.substring(11);
        }
        final int p = Integer.parseInt(name);
        final TCPServerSocket s = new TCPServerSocket(p, backlog, local);
        return s;
    }

    private ServerSocket newServerSocket(final int port, final int backlog) throws IOException {
        try {
            if (this.local) {
                return new ServerSocket(port, backlog, InetAddress.getByName("127.0.0.1"));
            }
        }
        catch (UnknownHostException ex) {}
        return new ServerSocket(port, backlog);
    }

    private void findFreePort(final int start, final int backlog) {
        int port = start;
        while (port < start + 100) {
            try {
                this.sock = this.newServerSocket(port, backlog);
                this.port = port;
                return;
            }
            catch (IOException e) {
                ++port;
                continue;
            }
        }
    }

    private TCPServerSocket(final int port, final int backlog, final boolean local) throws IOException {
        this.local = local;
        if (port == 0) {
            this.findFreePort(TCPServerSocket.TCP_PORT_BASE, backlog);
        }
        else {
            this.sock = this.newServerSocket(port, backlog);
            this.port = port;
        }
    }

    @Override
    public void close() throws IOException {
        this.sock.close();
    }

    @Override
    public Socket accept() throws IOException {
        final Socket s = this.sock.accept();
        s.setTcpNoDelay(true);
        return s;
    }

    @Override
    public String getSocketName() {
        return String.valueOf(this.port);
    }

    @Override
    public String toString() {
        return (this.local ? "INET_LOCAL:" : "INET:") + this.getSocketName();
    }

    static {
     //   TCPServerSocket.TCP_PORT_BASE = 9267;
        TCPServerSocket.TCP_PORT_BASE = 8080;
    }
}

在我的单机版中,我只能强制8080端口使用这个代码

public void init(final String[] s) {
    String sockname = null;
    int logLevel = -1;
   // final String tcpSocketName = "9267";
    final String tcpSocketName = "8080";
    if (s.length > 3) {
        this.checkOption(s);
    }
    try {
        if (s.length > 0) {
            sockname = s[0];
            if (sockname.startsWith("-")) {
                this.checkOption(s);
            }
        }
        try {
            if (s.length > 1) {
                logLevel = Integer.parseInt(s[1]);
            }
        }
        catch (NumberFormatException e2) {
            this.usage();
        }
        catch (Throwable t) {
            t.printStackTrace();
        }
        if (s.length == 0) {
            try {
             /*   final int tcpSocket = Integer.parseInt(tcpSocketName);
                final int freeJavaPort = findFreePort(tcpSocket);
                final int freeHttpPort = findFreePort(8080);
                final int freeHttpsPort = findFreePort(8443);
                final Object result = JOptionPane.showInputDialog(null, "Start a socket listener on port", "Starting the PHP/Java Bridge ...", 3, null, new String[] { "INET_LOCAL:" + freeJavaPort, "INET:" + freeJavaPort, "HTTP_LOCAL:" + freeHttpPort, "HTTP:" + freeHttpPort, "HTTPS_LOCAL:" + freeHttpsPort, "HTTPS:" + freeHttpsPort }, "HTTP_LOCAL:" + freeHttpPort);
                    //final Object result = 8080;
                if (result == null) {
                    System.exit(0);
                }*/
                //sockname = result.toString();
                sockname = "8080";
            }
            catch (Throwable t2) {}
        }
        if (s.length == 0) {
            TCPServerSocket.TCP_PORT_BASE = Integer.parseInt(tcpSocketName);
        }
        if (checkServlet(logLevel, sockname, s)) {
            return;
        }
        final ISocketFactory socket = bind(logLevel, sockname);
        if ("true".equals(System.getProperty("php.java.bridge.test.startup"))) {
            System.exit(0);
        }
        JavaBridge.initLog(String.valueOf(socket), logLevel, s);
        JavaBridge.init(socket, logLevel, s);
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
}

如何解决我的问题??我试图在其他文件中搜索,但我仍然得到错误,如果我使用武力选择使用8080端口

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题