Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SocketException and Oracle

4 views
Skip to first unread message

tlas

unread,
Aug 10, 2001, 11:21:30 AM8/10/01
to
Hi all,

I have following problem. There is class which task is to read data from
socket. This class is stored in Oracle 8.1.7 EE database
and problem occurs only when invoked from database. When I run this class
from command line everything is cool but running from database I receive
following exception:

java.net.SocketException: recv() failed, errno = 9
Bad file number
at java.net.SocketInputStream.socketRead(SocketInputStream.java)
at java.net.SocketInputStream.read(SocketInputStream.java)
at java.net.SocketInputStream.read(SocketInputStream.java)
at java.io.FilterInputStream.read(FilterInputStream.java)
at knapp.KnappReader.readKnapp(KnappReader.java:108)
at knapp.KnappReader.readKnappFrame(KnappReader.java:155)
at knapp.Hal2Knapp.send(Hal2Knapp.java:227)
at knapp.Product.doProcess(Product.java:97)
at knapp.Hal2KnappMaster.process(Hal2KnappMaster.java:222)
at knapp.Hal2Knapp.run(Hal2Knapp.java:270)
at knapp.Product.createProducts(Product.java:151)

This occurs after 300-400 data is read. I noticed that it may have something
to do with threads ( thread is used to catch timeout when reading ). Without
thread I managed to send/receive 10 000 data and nothing happened. Does
anyone have any idea what's wrong or maybe there is another way to implement
timeout catching without using threads.

In code below I'm using Timer class from java.util but I guess it uses
threads so it doesn't matter. Without using ReadTimer class everything is
OK.

<code>
public byte[] read() throws IOException, KnappException {
ReadTimer rt = null; //ReadTimer extends java.util.Timer
byte[] b = new byte[1];
b[0] = 0;
Field f = new Field(1 + Constants.TRANSMISSION_DATA_LENGTH +
1,"readKnappFrame");
Integer timeOut = getTimeout();

try {
if (timeOut == null) {
rt = new ReadTimer(this);
} else {
rt = new ReadTimer(this,timeOut.intValue());
}

while (true) {
b[0] = (byte) read();
f.appendBytes(b);
if (b[0] == Constants.END_CHARACTER) {
break;
}
if (b[0] == -1) {
throw new EndOfStreamException();
}
}

if (rt != null) {
rt.cancel();
rt = null;
}
} catch (IOException e) {
if ((rt != null) && (rt.isclosed)) {
throw new KnappException("Timeout");
}
else {
System.out.println("End Of Stream");
throw e;
}
}
finally {
if (rt != null) {
rt.cancel();
rt = null;
}
}

return(f.getBytes());
}

</code>


Thanks

Tomek

0 new messages