Socket - Send info to all clients?

Hi I've tried the Sockets Tutorial on Sun and found it really great but one thing. It leaves out the idea of all clients being in touch with each other.
import java.io.*;
import java.net.*;
public class KnockKnockClient {
    public static void main(String[] args) throws IOException {
         Runtime.getRuntime().exec("java KKMultiServer");
        Socket kkSocket = null;
        PrintWriter out = null;
        BufferedReader in = null;
        try {
            kkSocket = new Socket("213.67.113.48"/*my IP*/, 4444);
               System.out.println(kkSocket);
            out = new PrintWriter(kkSocket.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
        } catch (UnknownHostException e) {
              System.out.println(e);
            System.exit(1);
        } catch (IOException e) {
            System.err.println(e);
            System.exit(1);
        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
        String fromServer;
        String fromUser;
        while ((fromServer = in.readLine()) != null) {
            System.out.println("Server: " + fromServer);
            if (fromServer.equals("Bye."))
                break;
            fromUser = stdIn.readLine();
         if (fromUser != null) {
                System.out.println("Client: " + fromUser);
                 //Send info to server thread
                out.println(fromUser);
        out.close();
        in.close();
        stdIn.close();
        kkSocket.close();
import java.net.*;
import java.io.*;
public class KKMultiServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = null;
        boolean listening = true;
        try {
            serverSocket = new ServerSocket(4444);
        } catch (IOException e) {
            System.err.println(e);
            System.exit(-1);
        while (listening)
                  //Starts a new thread for each client that connects to the port
            new KKMultiServerThread(serverSocket.accept()).start();
        serverSocket.close();
import java.net.*;
import java.io.*;
public class KKMultiServerThread extends Thread {
    private Socket socket = null;
    public KKMultiServerThread(Socket socket) {
     super("KKMultiServerThread");
     this.socket = socket;
     System.out.println(socket);
    public void run() {
     try {
         PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            //Gets what the client writes
         BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
         String inputLine, outputLine;
         KnockKnockProtocol kkp = new KnockKnockProtocol();
         outputLine = kkp.processInput(null);
             //Send back to client
             //This I would like to send to all clients and not just the one who wrote to the server
         out.println(outputLine);
         while ((inputLine = in.readLine()) != null) {
          outputLine = kkp.processInput(inputLine);
                 //Send back to client
                //This I would like to send to all clients and not just the one who wrote to the server
          out.println(outputLine);
          if (outputLine.equals("Bye"))
              break;
         out.close();
         in.close();
         socket.close();
     } catch (IOException e) {
         e.printStackTrace();
import java.net.*;
import java.io.*;
public class KnockKnockProtocol {
    private static final int WAITING = 0;
    private static final int SENTKNOCKKNOCK = 1;
    private static final int SENTCLUE = 2;
    private static final int ANOTHER = 3;
    private static final int NUMJOKES = 5;
    private int state = WAITING;
    private int currentJoke = 0;
    private String[] clues = { "Turnip", "Little Old Lady", "Atch", "Who", "Who" };
    private String[] answers = { "Turnip the heat, it's cold in here!",
                                 "I didn't know you could yodel!",
                                 "Bless you!",
                                 "Is there an owl in here?",
                                 "Is there an echo in here?" };
    public String processInput(String theInput) {
        String theOutput = null;
        if (state == WAITING) {
            theOutput = "Knock! Knock!";
            state = SENTKNOCKKNOCK;
        } else if (state == SENTKNOCKKNOCK) {
            if (theInput.equalsIgnoreCase("Who's there?")) {
                theOutput = clues[currentJoke];
                state = SENTCLUE;
            } else {
                theOutput = "You're supposed to say \"Who's there?\"! " +
                   "Try again. Knock! Knock!";
        } else if (state == SENTCLUE) {
            if (theInput.equalsIgnoreCase(clues[currentJoke] + " who?")) {
                theOutput = answers[currentJoke] + " Want another? (y/n)";
                state = ANOTHER;
            } else {
                theOutput = "You're supposed to say \"" +
                   clues[currentJoke] +
                   " who?\"" +
                   "! Try again. Knock! Knock!";
                state = SENTKNOCKKNOCK;
        } else if (state == ANOTHER) {
            if (theInput.equalsIgnoreCase("y")) {
                theOutput = "Knock! Knock!";
                if (currentJoke == (NUMJOKES - 1))
                    currentJoke = 0;
                else
                    currentJoke++;
                state = SENTKNOCKKNOCK;
            } else {
                theOutput = "Bye.";
                state = WAITING;
        return theOutput;
}As you see I wrote in commented that I'd like the Thread to send the String to all connected clients, is that possible? If so please tell me how this can be done.
//Thanks Considerate

Hi I've tried the Sockets Tutorial on Sun and found it really great but one >thing. It leaves out the idea of all clients being in touch with each other.Consider that the clients could receive data like jwenting says below which means all traffic MUST be routed through the server
OR you could also have the client open a Socket directly to the other client
and send the data sans server.
georgemc>     
Look into multicasting (google is your friend)Unless he wants guaranteed delivery.
sabre150>
but don't expect it to work for clients outside of your intranet.This is true and depending on your router you may not be able to implement a class D address.
jwenting>
So better keep a list of connected clients and loop through that to send the >notifications. Bingo!
(T)

Similar Messages

  • Problem in sending username to all clients in a chat programme

    this is a repeat of the problem which i had posted earlier,due to ambiguous subject
    i wrote a server programme but i want to show to all the clients when they connect to the server , the name of the clients online, however when i am running the programme i don't get the names and the rest of the programme is working fine .... please can anyone help ....
    import java.io.*;
    import java.net.*;
    public class MultiThreadChatServer{
        // Declaration section:
        // declare a server socket and a client socket for the server
        // declare an input and an output stream
        static  Socket clientSocket = null;
        static  ServerSocket serverSocket = null;
        // This chat server can accept up to 10 clients' connections
        static  clientThread t[] = new clientThread[10];          
        public static void main(String args[]) {
         // The default port
         int port_number=2224;
         if (args.length < 1)
              System.out.println("Usage: java MultiThreadChatServer \n"+
                           "Now using port number="+port_number);
             } else {
              port_number=Integer.valueOf(args[0]).intValue();
         // Initialization section:
         // Try to open a server socket on port port_number (default 2222)
            try {
             serverSocket = new ServerSocket(port_number);
            catch (IOException e)
             {System.out.println(e);}
         // Create a socket object from the ServerSocket to listen and accept
         // connections.
         // Open input and output streams for this socket will be created in
         // client's thread since every client is served by the server in
         // an individual thread
         while(true){
             try {
              clientSocket = serverSocket.accept();
              for(int i=0; i<=9; i++){
                  if(t==null)
                   (t[i] = new clientThread(clientSocket,t)).start(); // creating that many instanceas for the class clientThread
                   break;
         catch (IOException e) {
              System.out.println(e);}
    // This client thread opens the input and the output streams for a particular client,
    // ask the client's name, informs all the clients currently connected to the
    // server about the fact that a new client has joined the chat room,
    // and as long as it receive data, echos that data back to all other clients.
    // When the client leaves the chat room this thread informs also all the
    // clients about that and terminates.
    class clientThread extends Thread{
    DataInputStream is = null;
    PrintStream os = null;
    Socket clientSocket = null;
    clientThread t[];
    public clientThread(Socket clientSocket, clientThread[] t){
         this.clientSocket=clientSocket;
    this.t=t;
    public void run()
         String line;
    String name;
         try{
         is = new DataInputStream(clientSocket.getInputStream());
         os = new PrintStream(clientSocket.getOutputStream());
         os.println("Enter your name.");
         name = is.readLine();
         os.println("Hello "+name+" to our chat room.\nTo leave enter /quit in a new line\n The present users online are:");
    for(int i=0; i<=9; i++)
              if (t[i]!=null && t[i]!=this)
              t[i].os.println(name);
    for(int i=0; i<=9; i++)
              if (t[i]!=null && t[i]!=this)
              t[i].os.println("*** A new user "+name+" entered the chat room !!! ***" );
         while (true) {
              line = is.readLine();
    if(line.startsWith("/quit")) break;
              //if(line.startsWith("PM:")
              //for(int j=0;j<=9;j++)
              //if(line.getcharsAt(3,))
              for(int i=0; i<=9; i++)
              if (t[i]!=null) t[i].os.println("<"+name+"> "+line);
         for(int i=0; i<=9; i++)
              if (t[i]!=null && t[i]!=this)
              t[i].os.println("*** The user "+name+" is leaving the chat room !!! ***" );
         os.println("*** Bye "+name+" ***");
         // Clean up:
         // Set to null the current thread variable such that other client could
         // be accepted by the server
         for(int i=0; i<=9; i++)
              if (t[i]==this) t[i]=null;
         // close the output stream
         // close the input stream
         // close the socket
         is.close();
         os.close();
         clientSocket.close();
         catch(IOException e){};
    Edited by: pranay09 on Oct 12, 2009 1:16 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The "clientThread[] t" in the client code constructor is null. Initialize it .

  • Sending info to all remote clients

    Hi all, I'm creating a chat room application with EJB specification.
    When ever a client enters a message, I want all other clients to see it on the main screen. What sort of mechenism should I use for this?
    So I implement this code in my business logic?
    Thanks for your help.

    When ever a client enters a message, I want all other
    clients to see it on the main screen. What sort of
    mechenism should I use for this?Consider using Message Driven Beans.
    So I implement this code in my business logic? You would need a polling process from the client.

  • MultiClient servers: Send to all clients and only certain ones?

    I've got Multiclient servers down as far as the Sun Java tutorials go, but I'm having some trouble figuring out how to be able to have the server be able to send to both all clients listening, and be able to send to a certain client, identifiable by some name (I'm guessing by IP address or something). My main problems:
    I don't really know how to identify the threads.
    I can't seem to think of a way to be able to send to every client, or to send to one client.
    I don't really need any long code blocks, just an overview of the process and maybe steps.

    Every time a client 'logs on' you create a new instance of your client handler which holds the socket information etc. Maintain a map in the main server that maps user names to the client handlers and add a client handler to the map as it is created. To sent a message to all, send to all client handlers registered in the map. To send a message to one, lookup the associated client handler in the map and sent the message to that client.

  • My iMac suddenly has a USB problem. I can connect to drives and printers. I am able to pul info off from drives. When I try to send info to a drive or printer, the connection is lost. All USB ports appear to have the same problem. Can anyone help?

    My iMac suddenly has a USB problem. I can connect to drives and printers. I am able to pul info off from drives. When I try to send info to a drive or printer, the connection is lost. All USB ports appear to have the same problem. Can anyone help?

    Please do 2-3 SMC and PRAM resets back to back and retest. Also use new cables, they can go bad.
    Intel iMac SMC and PRAM resets

  • Updating Coordinates to All Clients

    Hey all. I was just wondering if someone could give me an outline, or a VERY general explanation of how i should organize this. What I am doing is whenever a client connects to my server (via an applet) they will be able to move a box around with the arrow keys, and they will be able to see everyones boxes that are connected to the server. I'm also not sure whether to use TCP or UDP for this. I'm not sure which is more efficient for a project like this.
    I am not asking anyone to program anything for me, I understand how the mechanics of my game are going to work, and i've already built a single player version, except slightly more complicated with a rotating image. I also understand how Sockets, and ServerSockets, and all that stuff works as well. The thing i really need help with is structure and organization of my networked program.
    1) Structure
    2) TCP vs UDP
    I'm looking for something along the lines of this.
    Server
    *Accepts connections
    *Sends connection to a World Object
    Client
    *Tries to connect to the Server
    *Runs the listeners and moves character
    *Sends position to server (or something, this is where i'm having trouble, how to update the positions of all my characters)
    *Receives others positions(?)
    World
    *Receives connections and coordinates and relays them to other clients.(?)
    *Keeps world attributes to send to other clients(?)
    How might one go about tranferring a set of numbers to all clients connected to a server. If in the server i have an ArrayList of sockets to send them to?
    Thanks so much for reading this, and i would really appreciate a reply!
    Message was edited by:
    PaRlOaGn

    Well, yes i understand what you're saying, just write the info to output stream. But sending the soldiers coordinates from the client to the server.. I'd need to send some sort of custom packet class through an object stream? Here let me explain: if you have multiple clients connected, say 6 people. And i have an ArrayList of coordinates, the client has to KNOW it's position in the ArrayList for starters, then send it's position logged with it's current coordinates through an output stream, then send the WHOLE ArrayList to all the clients once it reaches the server... i'm just confused as to a good way to do that.. I understand how streams work... yeesh.

  • Sending msgs to certain clients

    All I have blazeds setup and messages being send to the frontend consumers. How do I do an async message and send it to only 1 of the 3 connect client frontend channels. Is there a way to subscribe or select msgs from certain clientId's?

    Hi Dave,
    As usual, an interesting question..
    For this one, you have to have the source code to the Xtra to
    know exactly
    how it handles socket communication.
    For tcp sockets in general, it's the system that handles i/o,
    and each
    socket works independently.
    So, long as the app (the xtra) makes sure that data are
    copied to the
    socket's buffer soon as the system informs the app that it
    can send more
    data, then you have optimal performance - at least for the
    type of sockets
    the muXtra uses.
    As for your question, I'd say neither.
    When you send a message, it is converted to binary data and
    stored in the
    object's (not socket's) send buffer.
    Soon as all data are sent, and long as more messages exist in
    the sendque,
    then the next message is copied to the send buffer.
    So, if you send 2 messages to two users, it is possible that
    both messages
    are delivered to one of them, while the other is still
    receiving the first.
    "Dave C" <[email protected]> wrote in message
    news:fktrnq$cvh$[email protected]..
    > In a p2p application, when a message is being sent to
    multiple clients,
    > how does the instance performing the server function
    accomplish this?
    > Specifically, if the message is a large amount of data
    broken into
    > multiple packets, does it send all packets to client 1,
    then all packets
    > to client 2, etc? Or does it send packet 1 to all
    clients, then packet 2
    > to all clients, etc?

  • How to send echo msg to client after regular time to verify the client

    Hi
    I have socket program which used for communicating information. tow part client and server.
    I am having problem. that is I want to send a msg to client (like echo) after some time duration. so how to do that?
    help
    Kapila

    This is the run method of inner class. when the sever is ideal, the sever has to send the msg to client. I think that I want to declare the this part "byte[] b = byteConcatenate(header, responsefornac,response.length); and out.write(b);" elsewhere. first I want to check the server is ideal then if it is ok, send the msg to client.
    problem is how to recognise the client?
              * Description : This inner class is used for handling the client session
         protected class SessionPda implements Runnable
    //********************************** DECLARATION OF COMMON VARIABLES ******************************************
         protected     byte[]      request;
         protected     byte[]      response;
         protected      byte[]      header;
         protected      byte[]      requestforserver;
         protected      byte[]      responsefornac;
         protected      Socket      client               ;
    //********************************** DEFINE CONSTRACTOR********************************************************
              * Description : This method is using for getting the opening client socket
              * @param e
         public SessionPda(Socket client)
         try
         this.client      =      client;
         catch (Exception e)
              System.out.println(">>>>>>>>>>>>>> This is error is occured when getting the opened clint socket at the inner sessionpda class in serve.>>>>>>>>>>>>>>>>>");
                   SysLog.logError(java.util.logging.Level.SEVERE, this.toString(), "Sessionpda()", StackTraceUtil.getStackTrace(e));
         header                     =      new byte[HEADER_SIZE];
         request                =      new byte[PACKET_SIZE];
         response                =      new byte[PACKET_SIZE];
         requestforserver      =      new byte[PACKET_SIZE];
         responsefornac           =      new byte[PACKET_SIZE];
    //********************************** OVERRIDING THE RUN METHOD IN JAVA LANG THREAD ****************************************************
              * Description : The proccessing the cliet sessionpda
              * @param request
              * @param respons
              public void run()
              try
                   while (true)
                        in     =     new     DataInputStream(client.getInputStream())     ;
                        out     =     new DataOutputStream(client.getOutputStream())     ;
                   //PRINTING THE REQUEST INFO-----------------------------------
                        int     len     =     in.read(request,0,PACKET_SIZE)                    ;
                        String recvString = "";
         for (int i = 0; i < len; i++)
              recvString +=adjustString(Integer.toHexString( (int) (request)));
         // System.out.println("Request Information :"+recvString);
         //PEPARING TO TO PRCESS--------------------------------------
         for (int j = 0; j < PACKET_SIZE - 3 ; j++)
                   requestforserver[j] = request[j + 3];
         Process p = ProcessFactory.getProcess(request);
         boolean redo = p.doProcess();
         ISOMsg m = new ISOMsg();
    m = p.getResponse();
    m.setPackager(new ISO87BPackager());
    response = m.pack();
    //PEPARATRING TO SEND BACK THE RESPOND----------------------
    header[1] = (byte) (response.length + 5);
              header[3] = (byte) 00;
              responsefornac[0] = (byte) Integer.parseInt(NII.substring(1,3),16); //17;
              for (int k = 0; k < response.length; k++)
                   responsefornac[k + 1] = response[k];
              byte[] b = byteConcatenate(header, responsefornac,response.length);
              out.write(b);
              out.flush();
    String sendinString = "";
    for (int i = 0; i < response.length + 5; i++)
         sendinString +=
              adjustString(Integer.toHexString( (int) (b[i])));
    SysLog.logInfo(java.util.logging.Level.INFO,"Response \n"+ sendinString);

  • In AIR 3.x, a socket write()+flush() on a client will hang app if peer adverts TCP ZERO WINDOW

    In AIR 3.x, a socket write() + flush() on a client will hang (and freeze the entire app) if the socket peer advertises a ZERO TCP Window, i.e. no space available in peer receiver's socket buffer.
    AIR on Windows insists that the developer flush() the socket in order to write (any data at all).  When the peer (receiver) advertises a 0 byte tcp window, the client flush() call can sometimes take 10 seconds (i.e. 10000 milliseconds), whereas normally it should take 10 to 50 milliseconds.
    Additionally, AIR stayed in hung position.  Since the socket had TCP KEEPALIVE option enabled (at the server), the socket stayed open.  I let it stay hung overnight.  The next day when I rebooted the server, the socket got closed and finally the AIR program "RETURNED FROM the sock.flush()" call.  A timestamp before and after the call to flush() showed that the flush() call was in hung state for 56472475 milliseconds, i.e. 15.7 hours!  After it returned from the flush() call the AIR app was responsive and seemed to work properly.  Thus proving that it was indeed stuck (or blocked) on the flush() call for 15 hours trying to drain the data to a socket with zero tcp window condition.
    A tcp zero window condition on 1 socket hanging an entire app sounds concerning.
    Solution Suggestions:
    (1) What is needed is for the OutputProgress event to include a field for 'bytes that can be written safely without blocking on the socket', i.e. 'space available in underlying platform socket buffer' which would account for the socket send buffer size.
    (2) An alternative solution would be for AIR to provide a write-timeout setsockopt (or a writeTimeout() method on the socket), and return flush with an error (or EWOULDBLOCK), and call the OUTPUTPROG event only when there is enough space available.
    If there are any other workarounds, please let me know.
    Thank you.

    Question:  Does Adobe AIR expose the getsockopt() and setsockopt() calls on a socket?  It would be useful to apps to tune the io buffer sizes.
    Additional Details:
    RTT = 100+ milliseconds
    TCP Window Scaling enabled
    Secure Socket
    Hard to reproduce with plain TCP socket, but occurs without fail with SecureSocket.  Not knowing the underlying code base, am wondering if it is because the SSL encryption overhead (bytes) throws off the buffer available size compution in secure_sock.flush() .
    Thanks.

  • Sending an object from client to server always on button press

    What I need is to send an object from client to server but I need to make server wait until another object is sent. What I have is the JFrame where you put the wanted name and surname, then you create a User object with these details and on button press you send this object to the server. I just can't hold the connection because when I send the first object, server doesn't wait for another button click and throws EOFexception. Creating the while loop isn't helpfull as well because it keeps sending the same object again and again. The code is here
    public class ClientFrame extends JFrame {
        private JButton btnSend;
        private JTextField txfName;
        private JTextField txfSurname;
        public ClientFrame() {
            this.setTitle(".. ");
            Container con = this.getContentPane();
            con.setLayout(new BorderLayout());
            txfName = new JTextField("name");
            txfSurname = new JTextField("surname");
            btnSend = new JButton(new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    SSLSocketFactory f =
                            (SSLSocketFactory) SSLSocketFactory.getDefault();
                    try {
                        SSLSocket c =
                                (SSLSocket) f.createSocket("localhost", 8888);
                        c.startHandshake();
                        OutputStream os = c.getOutputStream();
                        ObjectOutputStream oos = new ObjectOutputStream(os);
                        InputStream is = c.getInputStream();
                        ObjectInputStream ois = new ObjectInputStream(is);
                        boolean done = false;
                        while (!done) {
                            String first = txfName.getText();
                            String last = txfSurname.getText();
                            User u = new User();
                            u.setFirstName(first);
                            u.setLastName(last);
                            oos.reset();
                            oos.writeObject(u);
                            String str = (String) ois.readObject();
                            if (str.equals("rcvdOK")) {
                                System.out.println("received on the server side");
                            } else if (str.equals("ERROR")) {
                                System.out.println("ERROR");
                        //oos.writeObject(confirmString);
                        oos.close();
                        os.close();
                        c.close();
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(ClientFrame.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        System.err.println(ex.toString());
            btnSend.setText("send object");
            con.add(btnSend, BorderLayout.PAGE_START);
            con.add(txfName, BorderLayout.CENTER);
            con.add(txfSurname, BorderLayout.PAGE_END);
            this.pack();
            setSize(200, 150);
            setVisible(true);
    public class TestServer {
        public static void main(String[] args) {
            try {
                KeyStore ks = KeyStore.getInstance("JKS");
                ks.load(new FileInputStream(ksName), ksPass);
                KeyManagerFactory kmf =
                        KeyManagerFactory.getInstance("SunX509");
                kmf.init(ks, ctPass);
                SSLContext sc = SSLContext.getInstance("TLS");
                sc.init(kmf.getKeyManagers(), null, null);
                SSLServerSocketFactory ssf = sc.getServerSocketFactory();
                SSLServerSocket s = (SSLServerSocket) ssf.createServerSocket(8888);
                printServerSocketInfo(s);
                SSLSocket c = (SSLSocket) s.accept();
                InputStream is = c.getInputStream();
                ObjectInputStream ois = new ObjectInputStream(is);
                OutputStream os = c.getOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(os);
                boolean done = false;
                User u;
                  while(!done){
                    u = (User) ois.readObject();
                    String confirmString = "rcvdOK";
                    String errorString = "ERROR";
                    if (u != null) {
                        System.out.println(u.getFirstName() + " " + u.getLastName());
                        oos.writeObject(confirmString);
                    } else if (u == null) {
                        oos.writeObject(errorString);
                is.close();
                s.close();
                c.close();
            } catch (Exception e) {
                    System.err.println(e.toString());
    }Thanks for any help, btw this doesnt need to be via ssl, the problem would be the same using only http. Please anyone help me:)
    Edited by: Vencicek on 7.5.2012 2:19
    Edited by: EJP on 7/05/2012 19:53
    Edited by: Vencicek on 7.5.2012 3:36

    Current code fails because it's sending still the same entity again(using while loop)No it's not. You are creating a new User object every time around the loop.
    which makes the system freezeWhich means that you are executing network code in the event thread. Don't do that, use a separate thread. At the moment you're doing all that sending inside the constructor for ClientFrame which is an even worse idea: you can never get out of there to the rest of your client program. This is a program design problem, not a networking problem.
    and doesn't allow me to set new parameters of the new entityI do not understand.
    I need to find a way to keep Server running even when the client doesn't send any data and wait until the client doesnt press the send button again to read a new object.That's exactly what happens. readObject() blocks until data is received.

  • Any way to combine multiple incoming streams and send it back to clients?

    I am trying to make a server that receives HUNDREDS of incoming audio streams and then combines them into one stream and send it back to all clients- like audio conferencing. Is it possible to combine those streams together into a single one and send it to the receiving ends? I read on some topics in the forum and there really doesnt seem to be any answers.
    Also, if its not possible to combine those streams then is the next "best" alternative be having the server send all the audio streams from everyone to everyone? Its going to take a lot of resources doing that i think... any ideas? Thanks!

    hi bgl. I read that thread and its a litle bit hard to follow. it seems that you managed to grab Bytes of the incoming audio stream and continuing grabing them in a loop. I guess you use the player to play the Bytes? I also dont really see how i can mix all the Bytes together from lets say 10 users. Can you show me an example of it? Like making an incoming stream into Bytes and playing it. I assume it would have the same effect as playing the stream using a player? thanks

  • Sending mail to all users in Messaging Server 5.2

    Hi,
    I'm trying to send mail to all the users in my mail server, but haven't been able to do it. I'm using a command called deliver which is found in /opt/iplanet/server5/bin/msg/store/bin . I've tried sending messages to all users but have been successful in sending only to one user. Got any ideas??

    To create a dynamic mailing list:
    http://docs.sun.com/source/816-6009-10/users.htm
    If you're familir with ldapmodify, you can locate the user's pab in the directory server, and remove what you find there, but, honestly, I'd talk to the user first.. . .. .
    A user can work around removal of such, very easily. Any mail client, and a copy/paste will do it.

  • RMI Callback messages can not be sent to all clients

    we I send a message to all clients using RMI Callback the message dont arrive to all clients when one or more clients is disconnected without removing themselves from the hashtable at the server side .
    how i can know if the client is disconnected before sending the message to him using RMI callback taking into account that the client dosnt tell the server when he has disconnected.
    please i want a solution to this problem.
    thanks

    You seem to be making this a little complicated. During the login (or sometime) have one of the parms that are passed back to the server be a remote object on the client. It can have a nice interface like
    public void callMe(Object obj) throws .... or you could get cute and add
    pubic void shutDown() throws.... but this could be handled in the other method.
    During the call the client becomes the server and the server the client. The callMe method has no clue as to what thread it is on so it should just quickly queue up whatever it has gotten and return. It should not be doing work that will effect the Awt thread. If the client is no longer there then you should be able to catch this on the server, and continue posting other clients.
    Howie
    Your question is very similar to what I'm currently
    researching. I've got the additional complication of
    detecting when clients crash without unregistering (in
    my case unlocking) a resource. I haven't written any
    test code yet, so don't shoot me if I'm wrong, but
    here is my general strategy.
    In order to implementing RMI callbacks, it looks like
    you must make both the clients and the server register
    themselves in the RMI Registry. Parameters sent
    through RMI method calls are done by value so
    you can't simply add a listener as you normally do.
    The server will put itself in the registry using a
    well known ID. The clients will get this reference
    and ask the server for a unique ID. They will then
    register themselves in the RMI registry using this
    value. The client will then tell the server that it
    is registered. I believe if the client object is
    wrapped in a WeakReference, then when the client dies
    or ends, the reference contained in the WeakReference
    will be null. The server will perform this check on
    all registered clients to determine which clients are
    still alive.
    ,Marcus

  • How can Webservice manage client sections and send back messages to clients

    Hi all.
    I am starting working with Webservice (jax-ws). Now i can make a good server side and on client side i can use method interface on webservice server side.
    But i want to make a advance feature as Server side manage client section and can send back message to client when Server change status...
    I know RMI and Corba can seems to support to send back messages to sections of cliens right ?
    So Webservice can do it ? Please help me !
    Thanks
    Diego
    Edited by: ThuCT on Sep 14, 2010 1:57 AM

    Hi all.
    I am starting working with Webservice (jax-ws). Now i can make a good server side and on client side i can use method interface on webservice server side.
    But i want to make a advance feature as Server side manage client section and can send back message to client when Server change status...
    I know RMI and Corba can seems to support to send back messages to sections of cliens right ?
    So Webservice can do it ? Please help me !
    Thanks
    Diego
    Edited by: ThuCT on Sep 14, 2010 1:57 AM

  • Lost all contact info.  All my Aps are there but all the data/progress is missing.  When I plug my iphone into the usb fto synch up with my itunes on the computer a message comes up and says "enter the password to unlock your

    Lost all contact info.  All my Aps are there but all the data/progress is missing.  When I plug my iphone into the usb fto synch up with my itunes on the computer a message comes up and says "enter the password to unlock your iphone backup file".  This is very frustrating

    I suggest trying the update again after an hour or two.  Sometimes, the notice that an update is available comes an hour or two before the developers actually sends the revised app out to be downloaded.

Maybe you are looking for

  • Unable to send email from content server

    Hi, I have a requirement of sending the notification email to user from the stellent when he subscribe to it.To test it i logged in to content server as sysadmin. Administration->Actions->Send test email. I had filled some dummy data and when i click

  • Primary key problem - Urgent! PLEASE, HELP!

    Hi all, I'm new here, and I have a stupid problem, I think. If someone could help me, I'll be grateful. I have to build a very simple JSP application using a few database tables, providing the base functionality: insert, update, delete, search. I'm u

  • What is program ID?

    hi, I am trying to make a simple outbound connection. While making an outbound connection from SAP to java, i have creted an object of JCO.Server type. JCO.Server srv[] = new JCO.Server[1]; srv[0] = new Server("xxxxxxxx","xxxxx00","JCOSERVER01",repos

  • Unable to Open Change Organisation Form

    Hi All, i have added Change Organisation - MRP, Change Organisation - CST Form Function to a custom Menu, and it does not show list of Inventory Organisation. and i have also added "Change Organisation" Self Service Function and now it shows my Defau

  • Access Issue Tracking Template

    I found on the Microsoft Website an Issue Tracking Template, is there any setup guide that accompanies this?