Thanks and Regards
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:.
santhosh babu el wrote:
this function contiously read data from server in real time process after 6 hours error generted is connection timed out in socket.write method .how solve the error "connection timed out problem" my client code is
java its develped in swing gui and my server code is c code. please help me how to slove connection timed out problem
Rob Prime wrote:.
Thanks and Regards
Satya Maheshwari wrote:Are you sure that the server was up when the error occurred?
Is it possible to provide the exception stack trace?
Additionally, you should be closing all the open io streams in the finally block.
Thanks and Regards
Satya Maheshwari wrote:Here's how you could use the finally block:
private void startrxtxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
starttxrxpacket();
}
private static void starttxrxpacket()
{
new Thread()
{
@Override
public void run ()
{
while (true)
{
synchronized (this) {
try {
wait(100);
status= recvrxtxpacket(recvbuffer);
if(status==1)
{
maskval1(recvbuffer, resultbuff);
Thread.sleep(1000);
}
} catch (Exception e) {
}
}
}
}
}.start();
}
private static int recvrxtxpacket(byte[] recvbuffer)
{
int i=0,j=0;
int serverport=3005;
String serverIP=iptext.getText();
OutputStream out =null;
InputStream in=null;
int sendbuffer[]=new int[14];
sendbuffer[0]=0x55;
sendbuffer[1]=0x55;
sendbuffer[2]=0xFF;
sendbuffer[3]=0xFF;
sendbuffer[4]=0x01;
sendbuffer[5]=0x05;
sendbuffer[6]=0x00;
sendbuffer[7]=0x01;
sendbuffer[8]=0x00;
sendbuffer[9]=0x01;
sendbuffer[10]=0xAA;
sendbuffer[11]=0xAA;
try
{
Socket socket=new Socket(serverIP,serverport);
System.out.println("socket connection");
out = socket.getOutputStream();
in = socket.getInputStream();
System.out.println("send some data");
socket.setSoTimeout(600000);
for(i=0;i<12;i++)
{
out.write(sendbuffer[i]);
}
System.out.println("write success");
socket.setSoTimeout(600000);
in.read(recvbuffer);
// readbuffer(recvbuffer);
System.out.println("read success");
out.close();
in.close();
socket.close();
return 1;
}catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
return 0;
// JOptionPane.showMessageDialog(null,e);
} finally
{
if((in!=null) && (out!=null))
{
in.close();
out.close(0;
}
}
}
madam i have make changes what you have posted but still my problem exist. i am error liseed beloe.please help me to slove these proble.i am having this problem for past 6 months
java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at beam.sendack1(beam.java:6520)
at beam.Process_beam1(beam.java:4868)
at beam.access$2100(beam.java:41)
at beam$LocalXYDataset$1.run(beam.java:3529)
please help me
Do not set lab on fire. Or this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|