I
iksrazal
I have a class, DAOBySocket, used in a multi-user server environment .
Instead of a DB, my data is recieved via a client socket invokation to
a mainframe. Getting the connection typically takes several seconds.
I'd like to create the connection, and while waiting, parse my data
recieved as a big xml file into a format I can then send over the
socket, and perhaps do some other setup.
I think this can be accomplished via SocketChannel and finishConnect()
..
SocketChannel sc = SocketChannel.open();
InetSocketAddress addr new InetSocketAddress(address,port);
sc.configureBlocking(false);
while (!sc.finishConnect())
{
MyData mydata = parseXml(xmlStr);
}
sendData(sc, mydata);
sc.close();
However, I'm having a hard time visualizing how to handle a connection
time out. Also how to synch the xml task ending and a succesfull
connection - this code overwrites the same data while waiting. As I
understand it, SocketChannel doesn't have a timeout, and defaults to
blocking mode unless I invoke configureBlocking(false) .
Any ideas?
iksrazal
Instead of a DB, my data is recieved via a client socket invokation to
a mainframe. Getting the connection typically takes several seconds.
I'd like to create the connection, and while waiting, parse my data
recieved as a big xml file into a format I can then send over the
socket, and perhaps do some other setup.
I think this can be accomplished via SocketChannel and finishConnect()
..
SocketChannel sc = SocketChannel.open();
InetSocketAddress addr new InetSocketAddress(address,port);
sc.configureBlocking(false);
while (!sc.finishConnect())
{
MyData mydata = parseXml(xmlStr);
}
sendData(sc, mydata);
sc.close();
However, I'm having a hard time visualizing how to handle a connection
time out. Also how to synch the xml task ending and a succesfull
connection - this code overwrites the same data while waiting. As I
understand it, SocketChannel doesn't have a timeout, and defaults to
blocking mode unless I invoke configureBlocking(false) .
Any ideas?
iksrazal