Forums Register Login

socket operation

+Pie Number of slices to send: Send
Hello Friends,

how to set the timeout for the operation?
my question is i have send a request to the server and
waiting for resonse. how to come out from that and continuew my operation
if the server is not responding.

How do you prevent Java from hanging on socket = new Socket(addr, port) line if the machine on the other end is not responding?

Is this possible in Java?

Thanks, Otis
+Pie Number of slices to send: Send
Chennarao,

I guess you cannot do that in one step. But you can break it up as such

int timeOut = 10;
int portNumber=80;
Socket socket = new Socket();
socket.connect(new InetSocketAddress("www.yahoo.com",portNumber),timeOut);
+Pie Number of slices to send: Send
thanks for ur reply ...

in my case i am successfully connected with servre with
the socket and waiting for some response from the server
if the server is failed OR some other problem for the server
i should come out ..how this will possible
chennarao
+Pie Number of slices to send: Send
I guess since you are creating a TCP/IP connection , if any one of the end points breaks down the connection will be broken automatically giving you an Exception.

So if your server crashed while u were waiting for some data from the server, your connection will be broken. So you need only worry about how to handle the exception. Does that make sense???
+Pie Number of slices to send: Send
This thread belongs in our Sockets and Internet Protocols forum. I'll move it there for you.
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 878 times.
Similar Threads
Works with JDBC/ODBC but not Direct JDBC
Why send interrupt to a thread?
Running a Socket server process in Tomcat
HELP !!!!!!
How to Close a Socket that is hanging on an I/O operation
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:19:19.