One Server Multiple Clients

Hello,
This server code accepts only one client connection at a time. However, I have several lines that are specifically for the server to accept more than one client. What do I need to do in addition for the server to recognize that it can accept more than one client at a time?
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import javax.swing.JFrame;
public class ServerTest
   public static void main( String args[] )
      Server application = new Server();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      application.runServer();
class Server extends JFrame
   private JTextField enterField;
   private JTextArea displayArea;
   private ObjectOutputStream output;
   private ObjectInputStream input;
   private ServerSocket server;
   private Socket connection;
   private int counter = 1;
   private ExecutorService serverExecutor;
   private MultiServer clients[];
   public Server()
      super( "Server" );
      enterField = new JTextField();
      enterField.setEditable( false );
      enterField.addActionListener(
         new ActionListener()
            public void actionPerformed( ActionEvent event )
               sendData( event.getActionCommand() );
               enterField.setText( "" );
      add( enterField, BorderLayout.NORTH );
      displayArea = new JTextArea();
      add( new JScrollPane( displayArea ), BorderLayout.CENTER );
      setSize( 300, 150 );
      setVisible( true );
   public void runServer()
      serverExecutor = Executors.newCachedThreadPool();
      try
         server = new ServerSocket( 12345, 100 );
         while ( true )
            try
               waitForConnection();
               getStreams();
               processConnection();
            catch ( EOFException eofException )
               displayMessage( "\nServer terminated connection" );
            finally
               closeConnection();
               counter++;
      catch ( IOException ioException )
         ioException.printStackTrace();
   private void waitForConnection() throws IOException
      displayMessage( "Waiting for connection\n" );
      connection = server.accept(); 
      serverExecutor.execute( new MultiServer(server, connection));     
      displayMessage( "Connection " + counter + " received from: " + connection.getInetAddress().getHostName() );
   private void getStreams() throws IOException
      output = new ObjectOutputStream( connection.getOutputStream() );
      output.flush();
      input = new ObjectInputStream( connection.getInputStream() );
      displayMessage( "\nGot I/O streams\n" );
   private void processConnection() throws IOException
      String message = "Connection successful";
      sendData( message );
      setTextFieldEditable( true );
      serverExecutor.execute(new MultiServer(server, connection));
      do
         try
            message = ( String ) input.readObject();
            displayMessage( "\n" + message );
         catch ( ClassNotFoundException classNotFoundException )
            displayMessage( "\nUnknown object type received" );
      } while ( !message.equals( "CLIENT>>> TERMINATE" ) );
   private void closeConnection()
      displayMessage( "\nTerminating connection\n" );
      setTextFieldEditable( false );
      try
         output.close();
         input.close();
         connection.close();
      catch ( IOException ioException )
         ioException.printStackTrace();
   private void sendData( String message )
      try
         output.writeObject( "SERVER>>> " + message );
         output.flush();
         displayMessage( "\nSERVER>>> " + message );
      catch ( IOException ioException )
         displayArea.append( "\nError writing object" );
   private void displayMessage( final String messageToDisplay )
      SwingUtilities.invokeLater(
         new Runnable()
            public void run()
               displayArea.append( messageToDisplay );
   private void setTextFieldEditable( final boolean editable )
      SwingUtilities.invokeLater(
         new Runnable()
            public void run()
               enterField.setEditable( editable );
  class MultiServer extends Thread
  public MultiServer(ServerSocket servers, Socket connection)
      servers = server;
  public void run(){System.out.print("Yes");}
}

Check out the "Supporting Multiple Clients" bit here: http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
Start a Thread for each client. I'd recommend you create a class:
class Client
    Socket socket;
    ObjectOutputStream out;
    ObjectInputStream in;
    ...any other client-specific data you need...
    public void sendMessage(String s) { ...send to this client...; }
   ...any other client-specific methods you need...;
}Create one of those when accept() gets a new connection, then start the thread for that client.
You may want to keep a LinkedList that contains all the Client objects. E.g. if you want to send a message to all clients you'd loop over the LinkedList and send to each in turn. Synchronize the list appropriately. Removing clients from the list when they close down can be interesting :-) so be careful.

Similar Messages

  • One Server multiple Subnets

    Hello All,
    I want to configure a single print servers for multiple subnets envorinment, i.e I have 10.0.0.0 network then I have 192.168.1.0 and some more subnets and networks .Can I have a single print server for all my users,If yes how can I achive this?
    Thanks in advance.
    Regards
    Divyendu

    divyendu_bhatt, you can use a router with teh layer 2 switch for vlans. For that you need to create Switched Virtual Interfaces (SVI). Use google to understand SVI and use of inline router...

  • Preview in Browser, One Server, Multiple Domains

    I work for a company that provides both web design and hosting services. All of our clients' sites are in sub directories of our /web/ directory on the server but their web addresses are set up as subdomains (clientname.mycompany.com). How can I make "Preview in Browser" work with this setup?
    Right now, it tries to take me to the Web URL that I have set in "Servers" in DW, followed by the internal server path of the file.
    What I need, is to have "Preview in Browser" open up something like;
    clientname.mycompany.com:port
    instead of;
    dw_web_url/serverpath/file.php
    Is that possible?
    Also, is it possible to "Preview in Browser" while working on a CSS file? For example, if I am working on /root/css/style.css and I press F12, Firefox would open up clientname.mycompany.com:port/index.php instead of dw_web_url/root/css/style.css

    Also, is it possible to "Preview in Browser" while working on a CSS file? For example, if I am working on /root/css/style.css and I press F12, Firefox would open up clientname.mycompany.com:port/index.php instead of dw_web_url/root/css/style.css
    I'm puzzled by what you expect this would show?  A CSS file has no display.
    I have no sense for how to make your first issue work.  Sorry.

  • Mavericks Time Machine Server - multiple client backups disappear and merge

    Hi there,
    In our environment, which is shop environment where many computers are worked on, we use a Mac Pro with roughly 5TB disk space running Mavericks server. Essentially, we rename the computers to be worked on (in the Sharing pane of System preferences), then use Time Machine to connect and backup using a Sharing Only account that exists on the server. The TM backups are verified using Migration Assistant by opening MA and making sure the option to restore is present, without the 'No Backup Volumes found' message, common with TM backups on the network. All OS's are backing up to our server, the oldest being 10.6 and the newest likely being 10.10 now.
    Recently, we have noticed some backups seemingly disappear from the server. Just this morning, I looked at a VERY large sparesbundle and got curious.
    Upon launching Migration Assistant and opening that very large sparsebundle, I was able to find all the backups that 'dissappeared'. This is very concerning, as all of these backups were verified using MA immediately after having been created.  Migration Assistant is quit, the system shut down, and the computer's work proceeds.
    A few bits of information:
    -Computers sometimes come in to our shop (Apple Authorized) not being able to boot, so their storage volume is booted either via target mode or plugged in to another known good mac via a RocketStor Thunderbolt Dock, or simply directly in to another Mac
    -if a computer boots it is backed up natively using it's own OS
    -All of this takes place using AFP connections, and over an enterprise network, but devices are all plugged in to the same switch (at this point).
    There seems to be no rhyme or reason to the disappearance of the backups, and they are very frustrating to attempt to locate when they 'go missing', especially since these backups are only looked for when a HDD is wiped and data is needed....
    Any help is appreciated! As stated earlier, we are an Apple warranty authorized shop in a collegiate environment. Thanks all!
    Best,
    Chris
    Message was edited by: cmburkhalter
    Updated to make it slightly more clear

    Linc Davis wrote:
    I have indexing turned off for all my drives
    I suggest you turn it back on, at least on the ones you want to back up.
    Is this necessary? It seems to do half the backup without it. If I remember correctly I have indexing turned off not only because I don't use it but also because it was hanging up/using a lot of CPU... If I absolutely must I will turn the indexing back on and wait for it to do its dirty business, but I'm a bit reticent in trading my problem for one that I don't really have an interest in solving.

  • Can anyone show me an example of multiple clients(RMI)?

    Hi.
    Can anyone show me one simple example of a server serving multiple clients using RMI?
    I know that I have to use thread but I'm not really use to it...
    Thank you :)

    You don't have to use threads, you don't have to do anything. Any RMI server will service multiple clients simultaneously.

  • Networking: problems servering multiple clients

    hi all
    i'm writing a simple client server system, with a multithread server, in order to serve multiple clients.
    the client's requests to connect to the server arrive to a port (ie 1025), and then the server, through a method returns to the client another port number, and then the comunication between them starts through the new port.
    all work very fine, but i tried, with 2 computers, to start two clients at the "same time" (with a gap of few milliseconds), and my system "crashes".
    i think that is a problem due to the second request that arrives while the comunication of the port from the server to the client happens.
    is there a way to "queue" the requests arriving to the 1025 port of my server?
    if i wasn't clear i can post some code
    thanx in advance
    sandro

    Yes, teh code I posted does nothing more then listen for incoming conections and create a new Thread wich gets the Socket created by the accept to play with. This will happen for any incoming connection on the right port and will always be handeled the same.
    As you'll see in the code i posted, there is some time between ServerSocket.accept returning a Socket and ServerSocket.accept being started again. This time shouldn't be to long to be sure the serversocket is listening for incoming connections when they arrive, so don't do to much inside the loop. If your system should handle a lot of connections simultaneously wou might have to optimise this be doing thing like having a few ClientThreads created allready to save the time of creating a new Thread. This becomes more important if you ClientThread is complex and slow to create. But when handelin less the say 25 clients you should be fine with this.

  • How to control one server with multiple clients via TCP/IP

    I am wanting to control a single server with multiple clients.  Only one client would be active at a time, so there would be no conflict.  I want to use TCP/IP.  So far, I have programmed a cluster that passes data back to the server with no problems.  The challenge come in when a second client is added to the mix.  I have't been able to figure out how to turn each client on and send the appropriate data and then turn it off so it doesn't keep sending the same data to the server. 
    Here are the things that I have considered and did some preliminary testing, but don't really know how to impliment:
    1.  Send a numeric on the front of the cluster packet that tells the server that data is on the way.
    2.  Send a boolean on the front of the cluster packet to somehow turn the server TCP/IP on.
    The problem I have found is that LabVIEW TCP/IP doesn't like to be turned on and off.  If it doesn't get the data it expects, it goes into a reset mode and that kills the response time.
    Any help?

    You should consider implementing a set of simple one-byte commands that can be sent back and forth between the Server and the Clients. You can base all of these ideas off the example in the Example Finder under Networking >> TCP and UDP called Multiple Connections - Server.
    You will have two loops in the server VI: one to wait for new connections, and one to send and receive data from the existing connections. For instance, after one of the clients connects, it can request control of the server to send data to it by sending the character "R" for request. Every time the send/receive loop of the Server executes, the first thing it can do is to check all the existing connections to see if any of the clients have sent a control request ("R"). If so, it will create a buffer (array) of control requests. This could be in the form of Connection IDs or indexes in the array for a particular Connection ID. Your choice.
    After the Server receives a request for contol, if it is not already under control by another client, then it can send a response to the first client on the control request list. For instance, the server could send the first client a "S" command for send. Note that after the clients send their control request, they should execute a TCP Read and wait indefinitely for the server to respond with the one-byte "S" command. Then, once the client in control is finished sending data to the server, it could send the character "X" telling the Server to release it from control.
    The example I mentioned above already does a similar thing. Note how when a client wants to disconnect, they send the letter "Q". You can see this in the Multiple Connections - Client VI. The Server then checks each individual connection to see if it's received this one-byte command, and if it has, it closes the connection to the client. This is what you would want to implement, but instead of having just one command, you'll have to distinguish between a few and build up a buffer of control requests.
    Finally, if a client does decide to disconnect in your application, they could send the command "Q" just like the example above. At this point, close the connection and remove that Connection ID from the array of connections. You will also have to handle the case that this client was in the request control waiting line when it disconnected, in which case you need to delete it from that array as well.
    This will definitely work for you, but it will take some work. Best of luck!
    Jarrod S.
    National Instruments

  • Multiple sockets - many client one server

    I have multiple clients (a handfull) that will be sending a lot of messages per second. I have one server that I want to handle all of those methods. From what I've seen, there are some good multi-threading examples out there. I have seen one or two things about using socketchannels. what is the best approach to this problem, and how does it work?

    jobocop17 wrote:
    I have multiple clients (a handfull) that will be sending a lot of messages per second. What is a "lot"?
    10 or 10,000?
    Is that the sustained rate or the burst rate?
    What is the size of each message?
    What processing must occur for each message?
    Must every message succeed? Must it succeed the first time?
    I have one server that I want to handle all of those methodsSimply might not be possible depending on the answers to the above. Or might be trivially simple.

  • RMI: multiple clients for one RMI server?

    Hi,
    We're thinking of making a RMI Server.
    However, can multiple clients access the same RMI Server at the same moment?
    So, if one client is connected to the RMI Server, what will happen with the other clients that want to work to do the same thing at the same moment ?

    all over the same port?
    so for example, 100 clients can work simultaneously on this simple server?
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface OkServer extends Remote {
        public String getOk() throws RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RMISecurityManager;
    import java.rmi.RemoteException;
    import java.rmi.Naming;
    public class OkServerImpl extends UnicastRemoteObject implements OkServer {
        public OkServerImpl() throws RemoteException {
        public String getOk() {
         return "ok";
        public static void main (String args[]) throws Exception {
              System.setSecurityManager(new RMISecurityManager());
              OkServerImpl OkSvr = new OkServerImpl();
              Naming.bind("OkServer", OkSvr);
    }

  • Multiple users logged into one server, each users printer has a different name, application needs ONE name to print to.

    Multiple users logged into one server, each users printer has a different name, application needs ONE name to print to. 
    I'm NOT in any way a Terminal Services expert and I need help trying to get an application program working in a multi-user environment.
    The issue is that the printer changes for every user that is logged in. The application needs to print NOT to the default printer, but to a "special" printer which is selected in the application... let's call it a label printer to simplify the explanation.
    You have your default regular printer, easy for the application to find that one, and then you have a special printer that labels get printed onto. The application needs to know what printer is the label printer. So we allow the user to select that in the
    application and the selection is stored in a config file in 
    C:\ProgramData\mfgr\prog\setting files
    I don't have access to the application so I can't change how this works.  
    In the "regular" world, selecting the label printer driver to use should be per machine, NOT per user. When a new user logs into a machine, the physical printer doesn't go "poof" and a new printer suddenly appear. Same printer for all
    users.
    Yet in terminal services, the physical machine is "merged" with the virtual machine on the server. And there can be many users logged in at the same time. So each users real machine (and real printer) is injected into the "fake" terminal
    services machine. The name of the printers is made unique for each user. So the printers DO go "poof" and change names depending on the user logged into terminal services.
    So user "A" logs in and sets up the application to print to "LabelPrinterForUserA" (or whatever the name of the printer happens to be), that setting is stored in the ProgramData subfolder, and all is well. Later, user "B" logs
    in, and when they print, the application tries to print to "LabelPrinterForUserA" which doesn't exist for user B or is only accessible by user A. If user B re-configures, that breaks it for user A. 
    SOLUTION 1: The way that /should/ work (in my mind) is that you define one "generic" printer in Terminal Services... call it "Virtual Label printer" and when the user wants to print to it, the print job gets re-directed back to whatever
    physical printer is actually connected to their local workstation. There is a map of virtual printer to actual printer depending on the current user. The application is told once to print to "Virtual Label Printer" for all users.
    SOLUTION 2: Or... there should be some way to make the ProgramData sub folders separate per user. E.g. when user "A" tries to access:
    C:\ProgramData\mfgr\prog\setting files
    they actually get 
    C:\UserData\UserA\AppData\mfgr\prog\setting files
    and user "B" gets
    C:\UserData\UserB\AppData\mfgr\prog\setting files
    So the question I have is: Does either of those solutions exist hidden somewhere in the setup of terminal server? Or is there another way around this issue that I don't know?

    I don't really have a "for sure" answer to this, but because people here can't seem to deal with a question that hasn't been answered I'll provide the best answer I did receive from ServerFault.com user Nathan:
    I can feel your pain with using old software on terminal servers ...the solution I've come up with definitely won't scale as it requires some manual configuration, but I've gotten this method to work with our label printers (which require to be
    printed to an LPT port...yep, that old).
    Share your USB-connected printers to the network on each machine. Then, have the user log in on aunique session for each of them
    (a TS account cannot be shared among computers for this to work) and install a network printer pointing to the USB one they shared. Try to use a DNS name to account for possible DHCP movements.
    After, it should work. Each user can do this since display names can be identical as long as the ports are different (which they are).
    This was clarified by the following series of comments:
    I think you are on to something here, and I originally advised the admin to do this. The problem he ran into is that it setup the printer names in the TS as "printer on usersworkstation"
    and he could not rename it except to change the "printer" to whatever. E.g. the "on userworkstation" remained. I believe there is another way of installing the printer which avoids this, but I can't find it. Ages ago, one used to do NET
    USE LPT2 \\computer\printer password /USER:domain\user /PERSISTENT:YES and then tell the driver to print to LPT2 –  James
    Newton Mar
    17 at 16:21   
    @JamesNewton That's actually the exact method we used. The way around the "network printer" part is to install it as local printer and map it to a TCP/IP port that way. –  Nathan
    C Mar
    17 at 16:28
    You mean in the case where the printers are TCP/IP connected and not local USB / LPT to the users workstation? That makes sense. Wonder if this will work for USB connected printers... –  James
    NewtonMar
    17 at 16:35   
    @JamesNewton You'd share the local printer on the client's PC then on the server connect via TCP/IP to it. You'd need static addresses or use DNS names if DHCP, though. –  Nathan
    C Mar
    17 at 16:51
    Ah. Yes. I see. Looks like the LPT thing should work even with a USB connected printer:superuser.com/questions/182655/… –  James
    Newton Mar
    17 at 17:09   

  • How to manage one wsp and dll for multiple clients in farm environment

    1. There is a product which is developed using C sharp , jquery,CSS and sharepoint object models which have been packaged into .wsp file. Whenever we introduce new functionality to the product we used to branch the
    previous code as a version , say Version 1.0 and new functionality of the product will in another solution. This is how we are managing the code in TFS as versions. Each newer version will have new functionalities. We do not give latest functionality for all
    the clients. Each client is having its own version of functionality. Technically in order to access the functionality, the wsp solution should be present in the solution repository which is available in SharePoint central administrator site. This solution
    will be deployed on the client’s site. We are following the above process in SharePoint standalone installation where we used to purchase dedicated server per client and installed sql, SharePoint foundation 2010 as standalone installation and adding the client
    related version of the code to the solution repository. Later host on the site which is created for that client purpose. This process is same for all the clients where we purchase individual server for each client .
        Now we want to host our product in farm environment of sharepoint foundation 2010 where we are going to try 3 level architecture. 
    • SQL Server-In this sever we are going to install sql server 2008R2 standard edition. Which should serve the database service for all the web applications/sitecollections which we are going to create in Web front end server.
    • Application server- In this server we are going to install the sharepoint as farm and will install search server express for serving search functionality for our product
    • Web front end server- In this server we are going to add this server to Sharepoint farm which we have created in application server. Here we are going to create web applications and site collections for all the clients.
    In this scenario how to manage multiple versions of same wsp solution?
    Another major issue w.r.t the architecture of the product and new approach for client deployment as follow.We have CSS, jquery files for serving the functionality.These files have been mapped to 14 hive folder.If any changes we do one of the jquery file or
    css file which is meant for latest version and not for old version, then how to manage this new functionality for that particular css or jquery file in 14 hive folder, since there is only one 14 hive folder. What is the best practice to make this happen? Another
    thing is, how to manage dll files for individual client?

    It sounds like you have a farm scoped solution at work. In that case you can only have a single instance of it per farm, you'd have to branch each version so they appear to be seperate solutions entirely (thus ruining your clients upgrade process).
    Bluntly i don't think a single farm can manage all your user environments.

  • Multiple websites on one server

    I've been trying to create multiple (two) websites on one server, with little luck. One sight works fine. I've tried creating a DNS entry for the new one, but I'm not sure what to set the IP to. I've tried many configurations of IP/hostname but nothing seems to work. Occasionally, the logs just disappear from the logs window.
    I've read on here that it's possible to run multiple sites off of one IP, so I feel like that is not the problem. Ideally, I'd like to have one of the sites not exist in the System/WebServer folder. If I place the site folder outside of that folder, do I have to add its folder as a share point and/or modify its permissions?
    Server version is 10.6.3

    I'm going to distinguish the web browser (client), the web server, and the DNS server here, and will treat these as running on three separate computers. You might have one or more of those co-located on one box, adjust these references to your configuration as necessary.
    The DNS translations are applicable only on the client; on the host box that is running with the web browser. The web server doesn't care about the DNS translation. The client needs the DNS to get the IP address of the web server, and it's off to the races from there.
    Again, DNS translations are not relevant the web server. The particular web server that gets selected (Apache Virtual Host, what Apple calls a "Site") based on some information that is passed within the http (don't start working with https quite yet) connection from the web browser into the web server.
    As for your DNS question, you'll probably want a CNAME (alias) entered in DNS database for the virtual hosts, even if you're awash with IP addresses. That alias must then match the name of the web server "Site". For testing, you can enter what amounts to CNAMES into /etc/hosts on the client, depending on your local set-up and your DNS server.
    By default, the connections to all virtual hosts are via port 80. Stay there for now.
    The web server selections are sensitive to the order of the "Sites" in the listing in Server Admin, too; you'll want the wildcard site (if you have that) at the end of the list.
    Here are some of the basics: [Apache Tips: One Web Server, Multiple Distinct Web Sites|http://labs.hoffmanlabs.com/node/1282]. Comments on that are welcome.

  • Multiple clients with same account on a single IMAP server

    Hi,
    I am connecting to a IMAP server using same account but from 2 different machines. From one machine a mark a message as SEEN=FALSE. But on the second machine, the flag will still be TRUE.
    Is there any way to co-ordinate between multiple clients so that all the clients are in sync.
    Regards,
    Nitin.

    I was able to resolve the problem using addMessageCountListener and messagesAdded method, as suggested by you.
    I am now facing another problem. Whenever a new message is received, code inside messagesAdded method gets executed. Here I am trying to spawn another thread and do some stuff. But this new thread is not starting at all. It goes into some JavaMail:EventQueue and does nothing. What is the concept of EventQueue here? How can I get this new thread executed?
    Also will there be synchronization problems in messagesAdded method. Say I received a message and I am processing it in the messagesAdded method. In the mean time another message comes up. How will this behave.

  • How does create a server with multiple Clients ?

    Any people can lead me .
    How does create a server with multiple Clients ?
    Thanks

    For a multithreaded server you will need a thread to listen and at least one thread per client. If the conversation is half duplex, one thread per client works very well, if it's full duplex you will find one thread to send and one to receive much easier to program.
    I posted a Simple Socket Server that uses 1+2*clients threads.

  • Multiple client chat server

    Thanks to the help I got from the good people of this forum today I modified the chat server program which I am making and now it is working a bit better. Right now it can accept several (up to 8) clients and store their open sockets in a SocketCollection list which can later be accessed so that messages get sent to all of them. Problem is that when I send a message, it is displayed instantaneously on the client that sent that message (my machine), but is displayed only after the other clients press enter on the other clients' machines (for testing purposes it was the same machine, different port opened for communication with server which is also on the same machine). To clarify that - all clients and server are the same machine (that shouldn't be a problem, right?). Code for printing incoming data for client program is below:
    while ((fromServer = in.readLine()) != null) {
                if (fromServer!=null){
                       System.out.println(fromServer);
                       System.out.println("print on client screen msg received from server");
                fromUser = stdIn.readLine();
                if (fromUser != null) {
              System.out.println("Client: " + fromUser);
              out.println(fromUser);
    }Code to deliver the message to all clients from the server application is below as well:
    while ((inputLine = in.readLine()) != null) {
                     PrintWriter multiOut;
                   for (int x=0; x<8; x++){
                         System.out.println("INSIDE MULTI-TELL FOR LOOP");
                         if (socketCollection[x]!=null){
                               Socket c=socketCollection[x];
                               try{
                                   System.out.println("tried to send to all\nSocket c = " + c);
                                   out=new PrintWriter(c.getOutputStream(), true);
                                       out.println(c.getInetAddress() + inputLine);
                                catch(IOException ioe){}
    }In the server's DOS window I can clearly see that it enters to display the message to multiple clients and it should send it. The sockets are all different and they point to different ports on different clients' machines. Maybe the problem is just in the client program's code. If you could help me out, it will be greatly appreciated. Thank you very much.

    The sockets get created one by one when each client connects. Afterwards when the thread is made, that socket gets copied into the SocketCollection array which can afterwards be accessed in order for the server to distribute the message to all its connected clients.
    The for loop in the second code example where it takes SocketCollection[x] and gets its outputStream and all that is where it prints the message and sends it to each client (sends it but it is not displayed on the client side until the client sends a message to the server again). My question is how to make it so the client does not have to send a message in order to see the server message (message to all clients) that was sent before.

Maybe you are looking for

  • Broken: PS script to recursively zips files into one zip file

    Hi I'd like a script which zips all files and subfolders older than a specified date. I've have spent a fair bit of time hacking with no luck. I'd greatly appreciate any help. AJ PS. This script seems to do the trick -  $folder = "C:\temp2\"   $zipFi

  • From FrameMaker to InDesign

    Hi, I am new to this forum, and I am new to InDesign. I have actually never used InDesign, but I have many years of experience with FrameMaker. My situation is that many of my clients are interested in switching from FrameMaker to InDesigen, which me

  • ITune Music Store song wont go back to my mac

    I updated my iPhone and iTunes to the latest versions this morning. I was looking and saw an album i wanted so i bought it. I plug my iPhone into my computer (the only computer i EVER plug it into. The the music i bought from my phone won't sync to m

  • After Effects Color Correction Eye Dropper

    I use the Color Correction Eye dropper for clothing videos and recently it stopped letting me select the dropper.  I've tried restarting the program and computer.  Would I need to re-install After Effects? 

  • Kstat_lookup() failing: "Not enough space"

    Hi, I have a peculiar problem. I'm looking up CPU statistics using kstat(), and I'm getting a failure in kstat_lookup() on some machines. Here is the relevant code: kstat_ctl_t* pKstatCtl; kstat_t* pCpuStats; if ((pKstatCtl = kstat_open()) == NULL) /