简体   繁体   English

套接字编程ConnectException

[英]Socket Programming ConnectException

Im trying a programming to build an app to send and receive messages it also uses everything is set and working except that the Connect Exception: it is constantly saying connection timed out... i have this code on working 我正在尝试一个编程来构建一个应用程序来发送和接收消息,它还使用所有内容均已设置并正常工作,除了Connect异常:它一直在说连接超时...我正在使用此代码

socket s = new socket(destination,8888);

then furthur using the outputstream at firstly initiating end and then 然后在最初启动端继续使用输出流,然后

socket d= new socket (sender,8888);

and then input stream at the receiving end and both system are well connect with the code 然后在接收端输入流,并且两个系统都与代码良好连接

ServerSocket ss = new ServerSocket(8888);
Socket b= new Socket();
b=ss.accept();

what could possibly be wrong?? 有什么可能是错的吗?

Alot of chat programs spawn a new Thread, when the connection has been made, have you considered that? 建立连接后,许多聊天程序会产生一个新的线程,您是否考虑过? if you just do 如果你只是做

   ServerSocket ss = new ServerSocket(8888);
   Socket b= new Socket();
   b=ss.accept();

And you program ends after this line, it could cause a timeout exception because the client instantly lost the connection, when the server closed down. 并且您的程序在此行之后结束,这可能会导致超时异常,因为在服务器关闭时客户端会立即失去连接。

if this is completely retarded, please provide more code, its hard to make assumptions about your implementation. 如果这完全受阻,请提供更多代码,这很难对您的实现进行假设。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 套接字编程,多线程编程。 错误:IOException:java.net.ConnectException:连接超时:connect - Socket programming, multithreaded programming. Error: IOException: java.net.ConnectException: Connection timed out: connect 线程“ main”中的异常java.net.ConnectException:连接被拒绝:connect套接字编程Java - Exception in thread “main” java.net.ConnectException: Connection refused: connect Socket Programming Java 线程“主”java.net.ConnectException 中的异常:连接被拒绝:套接字编程中的线程 Java - Exception in thread "main" java.net.ConnectException: Connection refused:thread in Socket Programming Java 套接字编程 - Socket Programming java.net.socket ConnectException ETIMEEDOUT - java.net.socket ConnectException ETIMEEDOUT 简单的Java套接字客户端,引发此ConnectException的原因是什么? - Simple java socket client, what throws this ConnectException? java.net.connectexception客户端套接字故障 - java.net.connectexception client socket failure 套接字编程服务器套接字超时 - Socket Programming Server Socket TimeOut 无法创建套接字:java.net.ConnectException:连接被拒绝:连接 - Unable to Create a Socket :java.net.ConnectException: Connection refused: connect 尝试使用Socket测试localhost端口上的连接并获取ConnectException - Trying to test connection on localhost ports using Socket and get ConnectException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM