Multi-client Server Design

Hello all,
I'm really looking for best practices on multi-client UDP or TCP servers. In reading the java tutorials, it seems like the way to go for multi-client TCP servers is a threaded application, with threads for each client connection. I haven't found out what one would do for a multi-client UDP application....
Anyways, I was hoping you might be able to point me to some tutorials/online learning resources that deal in design/best-practices.

Hello all,
I'm really looking for best practices on multi-client UDP or TCP servers. In reading the java tutorials, it seems like the way to go for multi-client TCP servers is a threaded application, with threads for each client connection. I haven't found out what one would do for a multi-client UDP application....
Anyways, I was hoping you might be able to point me to some tutorials/online learning resources that deal in design/best-practices.

Similar Messages

  • My Tcp/ip multi-client server is not passing the data string into the flatten to string vi

    I am using labview Multi-connection cleint and server to build my own multi-client server connection.
      The problem i am having is that the data does not get through the flatten to string vi. Would anyone be kind enough to tell me why is that happening? and what I do to fix it.
      Attached code . My goal is to send data to the client via tcp/ip and use the data to perform certain task.
      Thanks a whole lot
    Attachments:
    multiconnection-server.vi ‏39 KB
    multiconnection-client.vi ‏21 KB

    Instead, I decided to upload the code and recent mods I have made to it .
    see attached
    Attachments:
    multiconnection-clienttest.vi ‏43 KB
    multiconnection-servertest.vi ‏21 KB

  • OSX: multi client server app with NSNetService

    hello
    i have a small osx server app
    that uses NSNetService to manage connection and set up streams
    but it seems to stop advertising as soon as a clients connects
    how can i make it multiclient so it keeps advertising and when a new client connects uses the same streams ?
    thanks in advance
    nonnus

    superdeportivo wrote:
    Hello fellahs, as the title of this post says I'm making a client and server application. The server are supposed to handel several clients, and the communication is done true UDP. Out of interest why have you chosen UDP rather than TCP?
    I have got two questions concerning this. The first one is if a exception is throws in the server should I then send the exception back to the client in serialized form. If I choose to do this then I also would need to handel the exception classen to the client. Or should I send back a regular IOException and use it's init cause to define the exception which occured in the server. That is up to you, you can do either. I would do the first option.
    The second question is concerning the multi client support. If this is going to work then I would need to time-out the connection i the server environment, and I have not a clue about how long it should be?It should be long enough that you don't timeout a valid connection. There is no simple answer to this.

  • An rmi client server design problem

    I am implementng a networked cards game in java using rmi . The server keeps track of the turn of the players and activates ther clients(on an applet) whose turn it is to play .
    Both client and server call each others methods.
    Prblem one :
    Right now if a a client disconnects , a process run through all the clients active and gets a remote exception on the server and removes ALL the 4 players i nthat particulat group. If I want to save the state and allow any player to contuniue from there , how will I do it?
    Problem 2:
    How do I keep track of the time a client takes to play.
    If he takes longer than say 5 mintes , I should disconnect him.

    There seem to be two issues at stake: <b>catching the remote exception</b> and <b>multithreading</b> your application on the server.
    When a client disconnects "suddenly" (without logging off via remote method call to alert server), the remote method call by the server to all <i>n</i> players triggers a remote exception that must be caught and dealt with accordingly (do I understand that it is causing the application to exit at present?) When caught, you must identify which player is "gone" and remove that client from the pool of client objects.
    Right now, it sounds as if the app is NOT multithreaded. You can create a low-priority thread that looks at a time variable for each player to determine its last moment of play. This means every successful remote call from client-server or vice-versa will update that client's 'lastplayed' variable with (long) System.currentTimeMillis() for example.

  • Question about client/server design

    I designed a server for a particular service. On the client side, how could it know that the server is up and running? i.e. how to make the client know that the server with the particular service is available?
    Thanks.

    When client started, if use udp to check the serveres
    is running or not, I think it is difficult. For so
    many port and so many serveres, how can you check?A single defined port is used for the service query. Regardless of what you do something must be defined ahead of time.
    DHCP works this way. When the client starts up it does not even have an IP address. There is a defined DHCP port for this (which is actually configurable on server and client but is seldom changed from the default.)
    >
    So my suggestion is that when server started, it
    register itselfto a central server. Then central
    server will send some common request to those
    registered server. If some registered server cannot
    work, they will be removed from central server.Yes you can use a service manager process. Even with that process it will still require a defined port though.
    Services could be registered using push, pull or both. Normal the following interactions would occur for this system.
    - On start up the client service must locate the manager server. It can either use a broadcast or configured location.
    - Once the server is located the client service registers itself and the services it provides with the manager.
    - Finally some polling logic is needed to very that each end is still alive. One end (A) sends a poll message and the other(B) responds. If there is no response then A takes some action. And if B does not recieve a poll message after a given period it takes some action.

  • Chat Programm for multi client-server on LAN

    import java.net.*;
    import java.io.*;
    public class ChatClientThread extends Thread
    {  private Socket           socket   = null;
    private ChatClient client = null;
    private DataInputStream streamIn = null;
    public ChatClientThread(ChatClient client, Socket socket)
    client = _client;
    socket = _socket;
    open();
    start();
    public void open()
    try
    streamIn = new DataInputStream(socket.getInputStream());
    catch(IOException ioe)
    System.out.println("Error getting input stream: " + ioe);
    client.stop();
    public void close()
    try
    if (streamIn != null) streamIn.close();
    catch(IOException ioe)
    System.out.println("Error closing input stream: " + ioe);
    public void run()
    while (true)
    try
    client.handle(streamIn.readUTF());
    catch(IOException ioe)
    System.out.println("Listening error: " + ioe.getMessage());
    client.stop();
    public static void main(String args[])
    }

    Refer to the response here:
    http://forums.sun.com/thread.jspa?threadID=5428090

  • Client server protocol book

    Hi, i want to create a program with applet clients communicating each other by a server. I'm looking for a book about a protocol for this purpuse. Thanks

    No recommendations, but note that you're dealing with a lot of parts:
    1) Java generally
    2) Java applets in particular
    3) the HTTP protocol
    4) server-side programming
    5) (if you feel it's necessary) client/server design in general
    There will be books on all of these. The more you know in general is a good thing, but I suspect that you can skip (5), get just a brief overview of (3), make sure you know (1), and read a tutorial on this site for (2). The trickier part will probably be (4).

  • Client/socket design problem

    i am having a client /server design where in the client talks to the server via sockets and i am putting code ofboth the client as well as server in the different loop while(true) at respective ends so that they can talk as long as they would like to but the client hangs upon receiving response from server . please guide me what to do.
    the client side code is
    while(true)
    temp1=clientbfr.readLine();
    //System.out.println(temp);
    if(temp1==null)
    else if(temp1.indexOf("Login-")==0)
    System.out.println(temp1);
    temp1="";
    the server side code is the same and that works fine. again if a second clinet requests a socket to the server then that client also hangs. so i think i am not able to view the picture properly. please guide me.

    Is the server reading before writing? If so, the client will hang until it has sent something for the server to reply to.

  • Design Pattern for multithreaded client server program

    I asked this question in another post, but with other stuff, so I'll distill this one.
    I am creating a multi-threaded client server program (just for learning - a chat program at this point). I built the server and client in swing, and I'm wondering what the best design pattern is for this setup. Right now all the swing stuff is in the MyServer class. In that class I have a loop accepting client connections to the serverSocket and creating a new MyServerThread (threaded client connection).
    The problem is that all the work of creating input streams, interacting with the server, all that stuff is done in the MyServerThread class, but I want that text to be written up to the Swing objects - which is in the MyServer class. So right now in the MyServerThread class I pass the MyServer object into it, but I'm not sure if that is really the most robust thing to do. Does anybody have any suggestions as to how this should be done. If somebody has an article they'd like to point to I'll check it out too. But if it's just the run-of-the-mill multithreaded client-server article, I've read alot and most don't specifically address my question.

    Thanks for the reply Kaj, and I think I'll keep my design for now, since it's just quick and dirty. I've read the MVC concept a while ago and I'll revisit it again when I get more serious. But I have a question, why should I be using a callback interface, why an interface at all? And then make MyServer implement that interface...why not just pass MyServer to the thread object? Or is there something down the line that I did not forsee?

  • Multi-Client TCP Server /w Swing GUI

    Hi everybody,
    i have to develop a Multi-Client TCP Server with a Swing GUI. The GUI mainly consists of a JTable which shows various trace messages from processes running on other computers. As the data needs to be filtered i�m using a custom TableModel derived from AbstractTableModel. I�m creating a new thread for every client that connects as shown in http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html
    Now every client thread reads data from its TCP connection and puts it into the JTable by calling the method addRow of the model. But i�m getting strange NullPointerExceptions and IndexOutOfBoundExceptions when data arrives (i�m using ArrayList in the model). These exceptions never show in a single-threaded Swing app (i�ve tested this already, so i don�t think it�s a bug in my model), so i think this is a problem with Swing�s thread unsafety? Do you have any hints on how to get away with it? Also general design tips for a Multi-Client TCP Server /w Swing GUI are greatly appreciated.
    Thanks in advance!
    Best regards,
    Disposable_Hero

    Of course, but i don�t think it is the model (as said before it works fine in a single thread swing app)
    Here�s the code:
    public class LogTableModel extends AbstractTableModel{
    private Vector dataVector;
    private Vector filterVector;
    private String[] columnIdentifiers;
    private Vector filteredbyProcess;
    private Vector filteredbyLoglevel;
    private boolean bEnableRefresh;
    /** Creates a new instance of LogTableModel */
    public LogTableModel() {
    dataVector=new Vector(0);
    columnIdentifiers=new String[]{"LogTime","HostName","IP","ProcessName","LogLevel","Handle","PID","TID","LogData"};
    filteredbyProcess=new Vector(0);
    filteredbyLoglevel=new Vector(0);
    filterVector=new Vector(0);
    bEnableRefresh=true;
    public synchronized void enableRefresh(boolean bEnableRefresh){
    this.bEnableRefresh=bEnableRefresh;
    if(bEnableRefresh){
    this.buildIndexListBasedOnFilter();
    public synchronized void addRow(LogLine row){
    dataVector.add(row);
    if(bEnableRefresh)
    this.buildIndexListBasedOnFilter();
    public synchronized void addFilter(Filter filter){
    filterVector.add(filter);
    if(filter.isActive())
    this.buildIndexListBasedOnFilter();
    public synchronized void setFilterActive(String name,boolean active){
    int i;
    for(i=0;i<filterVector.size();i++)
    if(((Filter)filterVector.elementAt(i)).getName().equals(name))
    break;
    Filter tmp=(Filter)filterVector.elementAt(i);
    tmp.setActive(active);
    if(active)
    this.buildIndexListBasedOnFilter();
    public synchronized void setFilterLoglevel(String name,int Loglevel){
    int i;
    for(i=0;i<filterVector.size();i++)
    if(((Filter)filterVector.elementAt(i)).getName().equals(name))
    break;
    Filter tmp=(Filter)filterVector.elementAt(i);
    tmp.setLoglevel(Loglevel);
    if(tmp.isActive()==false)
    this.buildIndexListBasedOnFilter();
    private void buildIndexListBasedOnFilter(){
    filteredbyProcess.clear();
    filteredbyLoglevel.clear();
    applyProcessFilter();
    applyLoglevelFilter();
    if(bEnableRefresh)
    this.fireTableDataChanged();
    private void applyProcessFilter(){
    LogLine line=null;
    Filter filter=null;
    for(int i=0;i<dataVector.size();i++){
    for(int j=0;j<filterVector.size();j++){
    filter=(Filter)filterVector.elementAt(j);
    line=(LogLine)dataVector.elementAt(i);
    if(filter.isActive()&&(filter.getName().equals(line.getProcessName()))){
    line.setHidden(true);
    break;
    else{
    line.setHidden(false);
    if(line.getHidden()!=true)
    filteredbyProcess.add(new Integer(i));
    private void applyLoglevelFilter(){
    for(int i=0;i<filteredbyProcess.size();i++){
    int index=((Integer)filteredbyProcess.get(i)).intValue();
    LogLine line=(LogLine)dataVector.elementAt(index);
    for(int j=0;j<filterVector.size();j++){
    if(((Filter)filterVector.elementAt(j)).getName().equals(line.getProcessName())){
    Filter filter=(Filter)filterVector.elementAt(j);
    if((filter.getLoglevel()&line.getLogLevelAsInt())!=line.getLogLevelAsInt())
    line.setHidden(true);
    else
    filteredbyLoglevel.add(new Integer(index));
    break;
    public synchronized String getColumnName(int columnIndex){
    return columnIdentifiers[columnIndex];
    public synchronized void clearData(){
    dataVector.clear();
    filteredbyProcess.clear();
    filteredbyLoglevel.clear();
    public synchronized int getColumnCount() {
    return columnIdentifiers.length;
    public synchronized int getRowCount() {
    return filteredbyLoglevel.size();
    public synchronized Object getValueAt(int rowIndex, int columnIndex) {
    int iIndex=((Integer)filteredbyLoglevel.get(rowIndex)).intValue();// hier krachts warum???
    LogLine tmp=(LogLine)dataVector.elementAt(iIndex);
    switch(columnIndex){
    case 0:
    return tmp.getLogTime();
    case 1:
    return tmp.getHostName();
    case 2:
    return tmp.getIP();
    case 3:
    return tmp.getProcessName();
    case 4:
    return tmp.getLogLevel();
    case 5:
    return tmp.getHandle();
    case 6:
    return tmp.getProcessID();
    case 7:
    return tmp.getThreadID();
    case 8:
    return tmp.getLogData();
    default:
    return null;

  • Need help in setting up a Multi Client chat server.

    I've been stuck at this problem longer than I should be, and it's starting to get to me.
    In my quest to learn more about networking in Java, I've decided to start with a simple multi client chat program. The problem is that I don't know exactly how to go about setting it up.
    I can't think of any way for multiple threads to be able to send data to the central server so that can then be sent to every other client, and also be able to request data and have it sent back just to the client that requested it.
    I think part of my problem might be that my knowledge of threads is somewhat limited, and that I might be overlooking or over complicating something.

    If you're trying to develop webapplications then I'm not too sure if SunONE 6.1 is the best platform considering that its support for jsp, servlets and the likes is rather outdated. Personally I'd look into http://www.sun.com/download/products.xml?id=446518d5 (Java webserver 7 rc3) if you wish to continue using a webserver with integrated java container.
    Otherwise you might benefit more from https://glassfish.dev.java.net (project glassfish), which is naturally also included in the http://java.sun.com/javaee (Java EE5).
    Just my 2 cents.

  • Are there any Client/Server Application (using sockets) design patterns?

    Hi,
    The title of the post nearly says it all. I am searching for different design patterns related with the development of a client/server application. I understand that there must be any different ways on how a client/server application can be developed.
    Regards,
    Sim085
    Disclaimer:
    When I enter in the Socket forum on this site I recieve this message "Thank you for any participation in this forum. Due to a lack of relevant activity, we have decided to archive this forum on June 16, 2006. For future posts on this topic, we suggest you use the Networking forum" and I am not allowed to create a new post! However I can see posts done yesterday! All i did is add the forum in 'my forums'. Does this happen to you people as well?

    Hi Sim085...How are you?
    So look this:
    http://forum.java.sun.com/thread.jspa?threadID=5148926&tstart=75
    I don�t know if is what you want...but I hope in this^^
    Ok man...If you have one example for help you is better.
    [ ]

  • Headstart Designer 6i. Install into Production Environment as Client/Server

    Hi,
    We are using designer 6i with headstart installed. We already have it installed in one 8i database running on an NT server but now we need to deploy it in a different 8i database. The associated documentation relates to a web server enviroment. Can you provide the steps or documentation to install this on a client server environment?
    Thanks

    Paul,
    You're right.. You shouldn't ;-D But a good hack is hard to resist. Therefore, create the following view:
    create or replace view my$version as select replace(banner,'Personal ') banner from sys.v_$version;
    Now, create a synonym named v$version to this view.
    The neatest way to do this is to create the view my$version view in your HST schema, and create a grant and a private synonym to this view in the schema's that you use to run the Forms:
    create synonym v$version for <HST_OWNER>.my$version
    But if you're bold enough you could also remove the existing public synonym v$version (which points to sys.v_$version), install the my$version view in the SYS schema and create a new public synonym:
    create public synonym v$version for my$version;
    And remember, you never heard this from me ;-D
    Kind regards,
    Peter
    null

  • How to design socket client-server app for 2-way communication

    Hi, I am writing a client-server application. I have a single server and many clients. Each client will need the ability to send information to the server at any time. The server will also need the ability to send information to a client at any time. Its this second part that I am not sure how to design. Would I need to create a SocketServer on each client to accept incoming messages, or is there a better way? Thanks

    scranchdaddy wrote:
    Don't my requirements sound a lot like an IM application, where a chat server might need to send a message to a chat client at any time?Not really. If that is what you are designing
    in my opinion one could easily be forgiven for thinking you were deliberately obfuscating your goal...
    How does the server know where the client is? Does it know the IP address of the client?I would imagine the server would contain a directory of IPs? I'm not sure.
    What happens if the client is not running?Then I guess the message would not get delivered.
    What happens if the client is behind a firewall that does not allow incoming connections?How do IM chat clients work? How have people solved this in the past?Typically the server would only care about clients currently connected to the server.
    Maybe you should re-think your design. I don't really have a design, just requirements, that's why I'm writing this post.Your subject says "+How to *design* socket client-server app for 2-way communication+".
    Are you saying you expect someone else to do the design for you?

  • Design a client-server system using java

    hello every body,
    I'm trying to design a client-server system using java,
    it work but the Qustion is:
    How can I send more than one mssg on the client side, and How can I recive more than one mssg on the client side?
    I tryed this:
    At client_
          System.out.println("Enter your Name:");
          BufferedReader stdIn1 = new BufferedReader(new InputStreamReader(System.in));
          String userName;
          userName=stdIn1.readLine();
          //sending message to the server
           out.println(userName);
          System.out.println("Enter your password:");
          BufferedReader stdIn2 = new BufferedReader(new InputStreamReader(System.in));
          String Passw;
          Passw=stdIn2.readLine();
          //sending message to the server
          out.println(Passw);
         BufferedReader stdIn3 = new BufferedReader(new InputStreamReader(System.in));
         String userInput;
         userInput=stdIn3.readLine();
         //sending message to the server
         out.println(userInput);
       //receiving message from the server and printing
       String revc;  
       revc=in.readLine();
       System.out.println(revc);
    At server_
        //reading from a client
          inputLine = in.readLine();
          outputLine = "Reply From Server :HelloClient ";
          //sending message to a client
          out.println(outputLine+"------"+ inputLine);
    i hope this is the right place for my question, and hope to get help
    thanks.

    Is there a reason you create a new InputStreamReader and a new BufferedReader every time you prompt for user input?
    lass_987 wrote:
    How can I send more than one mssg on the client sideInvokeout.println()more than once.
    How can I recive more than one mssg on the client side?Invokein.readLine()again.

Maybe you are looking for

  • Apple Customer Service and warranty exceptions

    Hello all, Whilst I love my Apple hardware and software, and have had many good experiences with them over the years, unfortunately I post today with a complaint about what I perceive to be poor customer service and product quality. In late March/ear

  • I have changed my e-mail address and changed it ok in apple and itunes but my iphone is still showing old e-mail address so I can't sign in and it won't let me change it

    I have changed my apple e-mail address in itunes and apple successfuly but now, every time I use my iphone 5 it is asking me to sign in but it still has my old e-mail address there so when I enter my password it says wrong id or password.  In setting

  • Sales Text

    Hi All,   I am working on Invoice Smartform ZLB_BIL_INVOICE.   In output i want to display sales text which is in MM02.For that i use include text in smartform in which i want to define TEXT NAME  Material sales organisation distribution Ch TEXT OBJE

  • Best practice - Migrate from WLC4404 to WLC5508

    Hello everyone, I would like to have pointers how to migrate from WLC4404 to WLC5508. I want to know your propositions. I could replicate the configuration manually but there is a lot of confirugation menus and all. If both could be online and migrat

  • Imovie 11 photos black.

    Hi. I have recently been trying to make movies with green screen in Imovie 11. Just recently when I put down an image to replace the background it turns out black. I have just tried putting down a regular picture (with out the green screen) and they