|
-
Client/Server Message Routing
I have a client/server application thatis very similar to a chat program where
the SERVER will need to send messages to a specific CLIENT.
The problem is that I do not know how to get an ID or THREAD ID for the ClientWorker
class after it is started.
IF you have any tips I would appreciate it!
Thanks,
Keith
HEre is my code so far:
package multiserver;
import java.net.*;
import java.io.*;
import java.lang.String;
class ClientWorker implements Runnable
{
public ClientWorker (Socket socket){
System.out.println("You are now in CLIENT WORKER");
}
public void run()
{
}
}
public class MultiServer {
boolean serverListening = true;
ServerSocket serverSocket = null;
public MultiServer() {
System.out.println("Starting Khrondar Multicast Server..");
// Start Server, obtain PORT, obtain INET Address //
try {
serverSocket = new ServerSocket(4444);
System.out.println("PORT resolved at [" + serverSocket.getLocalPort()
+ "]");
System.out.println("INET address resolved at [" + serverSocket.getInetAddress()
+ "]");
} catch (IOException e) {
System.err.println("Khrondar Multicast Server could not listen
on port: 4444.");
System.exit(-1);
}
System.out.println("Khrondar Multicast Server instantiated.");
System.out.println("Starting Khrondar Multicast Socket Listener.");
// SOCKET LISTENER //
while (serverListening)
{
try {
new ClientWorker(serverSocket.accept());
} catch (IOException io) {
io.printStackTrace();
}
}
}
public static void main(String[] args) {
MultiServer server = new MultiServer();
}
}
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks