Posted By:
Napstar_Star
Posted On:
Thursday, October 13, 2005 12:32 PM
private void getConnections()throws Exception{ selector = SelectorProvider.provider().openSelector(); sSC.register(selector,SelectionKey.OP_ACCEPT, null); while(selector.select()>0){ Iterator iterator = selector.selectedKeys().iterator(); while(iterator.hasNext()){ SelectionKey key = (SelectionKey)iterator.next(); iterator.remove(); if(key.isAcceptable()){ ServerSocketChannel nextReady = (ServerSocketChannel)key.channel(); SocketChannel socketChannel = nextReady.accept(); if(socketChannel!= null){ selected = socketChannel.configureBlocking(false); System.out.println("Socket added to the vector"+socketChannel.socket()); count2++
More>>
private void getConnections()throws Exception{
selector = SelectorProvider.provider().openSelector();
sSC.register(selector,SelectionKey.OP_ACCEPT, null);
while(selector.select()>0){
Iterator iterator = selector.selectedKeys().iterator();
while(iterator.hasNext()){
SelectionKey key = (SelectionKey)iterator.next();
iterator.remove();
if(key.isAcceptable()){
ServerSocketChannel nextReady = (ServerSocketChannel)key.channel();
SocketChannel socketChannel = nextReady.accept();
if(socketChannel!= null){
selected = socketChannel.configureBlocking(false);
System.out.println("Socket added to the vector"+socketChannel.socket());
count2++;
displayOnTheArea(outputArea, "Client number "+count2);
SelectionKey readKey = socketChannel.register(selector,SelectionKey.OP_READ);
}
}
else if(key.isReadable()) {
SocketChannel socketChannel = (SocketChannel)key.channel();
thread = setClass();
byte[] hold = thread.readData(socketChannel, readBuffer);
if(hold.length>290)
publicKey = hold;
if(publicKey.length>290 )
sessionKey = thread.generateSecretKey(publicKey);
count1++;
decrypt = new DecryptThread(socketChannel, connected, ka, con, pairs, sign, writeBuffer,
pubKey, outputArea, holdKeys, sessionKey, vector, holdData, count1,hold);
decrypt.start();
}
}
}
}
Hi guys I have the above code which I use to process incoming connections and data but my biggest problem is that on the client side the client sends two encrypted byte[] arrays so I don't how I can assign these two byte[] array to two different variables.Can anyone help me with this.Thanx I really appreciate your effort.
<<Less