什么可能导致“IO错误java.net.SocketException:select failed”? [英] What can cause “ IO error java.net.SocketException: select failed ”?

查看:229
本文介绍了什么可能导致“IO错误java.net.SocketException:select failed”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的笔记本电脑上运行的服务器程序,相同的路由器和相同的代码。它工作正常,客户可以连接。然而,当我将工作区复制到我的PC并运行它时,我得到了这个废话:

I have a server program running on my laptop, same router and same code. It work's fine and clients can connect. However when I copied the workspace to my PC and when I run it, I get this nonsense:

IO错误java.net.SocketException:select failed

IO error java.net.SocketException: select failed

这是代码......

Here is the code...

public static void main(String[] args) {
    System.out.println("running server!");
        int nreq = 1;
        try{
            ServerSocket sock = new ServerSocket(7331);
        for(;;){
            Socket newsock = sock.accept();
            System.out.println("Creating thread...");
            //Thread t = new ThreadHandler(newsock, nreq);
            //t.start();
            nreq++;
        }
        }

        catch(Exception e)
        {

            System.out.println("IO error  " + e);

        }

基本上可能导致此错误(我可以找到)没有在线的有用信息)在一台PC而不是另一台PC上发生?它必须与PC本身有关。我最困惑。基本上它无法打开套接字?

Basically what could cause this error (of which I can find no useful information online) to happen on one PC and not another? It has to be something about the PC itself. I am most confused. Basically it can't open a socket?

这是完整的堆栈跟踪:

java.net.SocketException: select failed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at Server.main(Server.java:18)

如果它是相关的,我在PC上使用Windows 7 64位Ultimate,这给我带来了麻烦。它工作正常的笔记本电脑是Windows 7 32位。因此,我能说出的唯一可辨别的差异是32比64比特。

If it's relevant, I'm using Windows 7 64 bit Ultimate on the PC which is giving me problems. The laptop that it works fine on is Windows 7 32 bit. So the only discernible difference I can tell is 32 vs 64 bit.

这可能是相关的吗?我不明白。
http://forums.codeguru.com/showthread .php?522257-Windows-Sockets-64-bit

Could this be relevant? I don't understand it. http://forums.codeguru.com/showthread.php?522257-Windows-Sockets-64-bit

推荐答案

我因为权限而遇到此问题。我更习惯于Linux,我需要检查IPTables的设置(或禁用它),权限,例如绑定到端口的非root用户< 1024.我相信在Windows上,您需要检查用户的管理权限和Windows防火墙。

I've run into this because of permissions. I'm more accustomed to Linux where I would need to check the settings for IPTables (or disable it), permissions such as non-root users binding to ports < 1024. I believe on Windows you'll want to check your user's administrative rights and your Windows Firewall.

这篇关于什么可能导致“IO错误java.net.SocketException:select failed”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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