|
-
Oct 16th, 2007, 12:14 PM
#1
Thread Starter
Frenzied Member
ComputerJy, I need your expert help on my small client/server app
Last edited by Pouncer; Oct 18th, 2007 at 05:42 PM.
-
Oct 16th, 2007, 11:53 PM
#2
Re: ComputerJy, I need your expert help on my small client/server app
I'm not sure if it will work but try this:
Code:
public static void sendMessageToClients(Selector selector, SelectionKey key, SelectionKey serverKey, String message) {
Set keys = selector[b].*******eys();
for (Iterator i = keys.iterator(); i.hasNext();) {
SelectionKey sel_key = (SelectionKey) i.next();
try {
// Skip if key is associated with server-socket channel.
if (sel_key.equals(serverKey)) {
continue;
}
// Otherwise get the socket-channel associated with the key.
SocketChannel client = (SocketChannel) sel_key.channel();
client.configureBlocking(false);
if (!client.isConnected()) {
client.connect(new InetSocketAddress(PORT));
while (client.isConnectionPending()) {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
}
}
I only added the last 6 lines just to make sure the client is connected to the server.
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|