[英]Socket Programming ConnectException
Im trying a socket programming to build an app to send and receive messages it also uses cryptography 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.