Server, thread and limited connexions

I use this code for my server. I got it from the book "Java thread" written by Scott Oaks and Henry Wong" and edited by O'Reilly.
This code works very good. I just want to implement a limited allowed connexions at a same time (ie 20 or 30 connexions possible at a same time).
I think a simple count of the created threads isn't enougth because i can't figure out how to decrease it. I was thinking using thread pool and counting the threads inside, so that i know exactly how many connexions are opened.
Any advice about this is welcome.
Here is the code :
import java.net.*;
import java.io.*;
public class TCPServer implements Cloneable, Runnable
    Thread runner = null;
    ServerSocket server = null;
    Socket data = null;
    boolean ShouldStop = false;
    public synchronized void startServer(int port) throws IOException
        if(runner == null)
            server = new ServerSocket(port);
            runner = new Thread(this);
            runner.start();
    public synchronized void stopServer()
        if(server != null)
            ShouldStop = true;
            runner.interrupt();
            runner = null;
            try
                server.close();
            catch(IOException ioe)
                //ioe.printStackTrace();
            server = null;
    public void run()
        if(server != null)
            while(!ShouldStop)
                try
                    Socket datasocket = server.accept();
                    TCPServer newSocket = (TCPServer) clone();
                    newSocket.server = null;
                    newSocket.data = datasocket;
                    newSocket.runner = new Thread(newSocket);
                    newSocket.runner.start();
                catch(Exception e)
        else
            run(data);
    public void run(Socket data)
}This class is used to implement the server. A derivated class is used to treat the connexion. I wish to implement the counter in this class if possible.
In advance thanks.

To define the maximum allowed connections, use this constructor for ServerSocket
public ServerSocket(int port, int backlog)Backlog being the maximum allowed connections at a time. Any aditional connection attempts will be rejected.
public class TCPServer implements Cloneable, Runnable{
    Thread runner = null;
    ServerSocket server = null;
    Socket data = null;
    boolean ShouldStop = false;
    private final int MAXIMUM_CONNECTIONS = 20; //or 30 or whatever you want your maximum to be
        public synchronized void startServer(int port) throws IOException {
        if(runner == null) {
            server = new ServerSocket(port, MAXIMUM_CONNECTIONS);
            runner = new Thread(this);
            runner.start();
    public synchronized void stopServer()    {
        //.......etc
}

Similar Messages

  • Thread number limitation on Sun One Web Server 6.1 on Solaris 9

    Hi.
    I am testing my servlet on Web Server 6.1 on Solaris 9 (SPARC). I am logging start of HTTPServlet.doPost() method and end of it, by calling GenericServlet.log() method for perfomance check.
    When I request more than two request(it takes long time) simultaneously from browser, my servlet logs like:
    doPost start
    doPost start
    doPost end
    doPost start
    doPost end
    doPost start
    :that is ,two requests is processed concurrent by threads, and another requests waiting, and after each running thread ends, waiting request is processed one by one.
    I think there is some limitation of thread or connections, so I checked magnus.conf. But RqThrottle is set to 128. And I cannot find any thread number settings.
    My magnus.conf is as follows.
    # The NetsiteRoot, ServerName, and ServerID directives are DEPRECATED.
    # They will not be supported in future releases of the Web Server.
    NetsiteRoot /export/home0/SUNWwbsvr
    ServerName test03
    ServerID https-test03
    RqThrottle 128
    DNS off
    Security off
    PidLog /export/home0/SUNWwbsvr/https-test03/logs/pid
    User webservd
    StackSize 131072
    TempDir /tmp/https-test03-8ac62f09
    UseNativePoll off
    PostThreadsEarly on
    KernelThreads off
    Init fn=flex-init access="$accesslog" format.access="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb.clf-request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%"
    Init fn="load-modules" shlib="/export/home0/SUNWwbsvr/bin/https/lib/libj2eeplugin.so" shlib_flags="(global|now)"Why web server do not process more than two requests concurrent? Which server configuration should I check?
    Thanks in advance.

    I don't think I ever ran into that kind of a limit. Does the servlet use database connections (maybe the connection pool is empty) or other critical sections / large synchronized blocks?
    Try a minimal servlet that takes a while to execute:
        doGet(...)
            log("sleep starting " + Thread.currentThread().getName());
            try {
                Thread.sleep(30000);
            } catch (Exception e) { }
            log("sleep done " + Thread.currentThread().getName());
            response.getOutputStream().println("good morning");

  • CF8 cfthread, server monitor, and active threads

    When I run this code:
    cfthread
    part III or any cfthread without a thread join and then go to
    the CF Administrator -> Server Monitor -> Statistics ->
    Active ColdFusion Threads, I don't see the threads ever going away.
    They just build and build everytime I run it. I can get it to
    go all the way up to 400+ threads and stay there untill I restart
    Jrun. I think this is a monitor issue because I'd hate to think
    those threads are tied up and still active.
    Thoughts?

    Neo,
    I have noticed the same thing. Now for the odd part. If you
    click the 'start monitoring' button and then run your thread test,
    the threads don't appear in the Active Coldfusion Thread report!
    When running our application, I noticed the Coldfusion thread
    count getting up to 80,000+ threads in the span of a couple of
    hours. If we can't figure out what is causing this, we are going to
    downgrade back to CF7

  • Iplanet portal server look and feel limitations

    does anyone know what's portal server look and feel limitations? Eg : what components that cannot be changed? Thanks a lot.:)

    Actually, you have an almost clean slate. You need to have some sort of header (though I suppose it could be 1 pixel high...), and by turning off the channel frames, you can eliminate the portal feel altogether. Take a look at www.tntvacations.com to see a portal server. The only way you can tell it is portal is through the URL... behind the scenes, it is set up with the thin-thick-thin channel layout, with 8 channel providers. The header and secondary menu components that are part of the customized desktop servlet.

  • Install AD / SQL Server 2012 and SharePoint 2013 on a single server as Development Environment

    Hi All,
          I'm planning to prepare a SharePoint 2013 development environment. The current idea is to install Domain controller, SQL Server 2012 and SharePoint 2013 all on a single server. Even though this is for development purposes,
    would there be any limitations specially when it comes to SP 2013 functionalities according to your experience?
    Some articles i referred.
    http://sharepoint-tutorial.net/post/2012/07/18/install-sharepoint-2013-domain-controller.aspx
    http://social.technet.microsoft.com/Forums/en-US/f438c9a6-02e8-43d3-9963-7a0608f0b961/sharepoint2013-on-domain-controller
    Thanks,
    Dilip

    Hi
    i understand this is a sandbox environment but you should be able to install everything.
    http://sharepoint-tutorial.net/post/2012/07/18/install-sharepoint-2013-domain-controller.aspx
    Hope this helps. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • SQL Server Agent and Jobs and executing @EventData

    I have a SQL Server Agent Job and within it a Job Step which states "Execute Report Subscriptions" and a command which has...
    exec msdb.dbo.sp_start_job '6FF53AED-855F-43AB-9FB7-064062B8012E' --9:07 subscription
    GO
    WAITFOR DELAY '00:08';
    Now, I find within SQL Server Agent the Job  '6FF53AED-855F-43AB-9FB7-064062B8012E' and its step command which is...
    exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='ca4e5410-2758-4a1a-9b06-513821e0d962'
    How can I drill-down further into the @EventData 'ca4e5410-2758-4a1a-9b06-513821e0d962' to see what it does? I do not see 'ca4e5410-2758-4a1a-9b06-513821e0d962' within SQL Server Agent and Jobs or am I way off base here as to what exactly the @EventData
    parameter seems to be?
    Thanks for your review and am hopeful for a reply.

    Hi ITBobbyP,
    According to your description, you need to know the what does SQL Server Reporting Services do when fire a subscription, right?
    When you create a subscription several things are added to the RS server
    A row is placed in the Subscriptions table identifying the name of the report, along with parameter settings, data driven query info and so on to process the subscription
    A row is placed in the Schedule and ReportSchedule tables with the timing of the subscription
    A SQL Server Agent job is created to control the scheduled execution of the report, and this is stored in the sysjobs and sysjobsteps of the MSDB database.
    When the subscription runs several things happen
    The SQL Server Agent job fires and puts a row in the Event table in the RS catalog with the settings necessary to process the subscription
    The RS server service has a limited number of threads (2 per CPU) that poll the Event table every few seconds looking for subscriptions to process
    When it finds an event, it puts a row in the Notifications table and starts processing the subscription
    Please refer to the links below to see the details.
    http://blogs.msdn.com/b/deanka/archive/2009/01/13/diagnosing-and-troubleshooting-subscriptions.aspx
    http://blogs.msdn.com/b/deanka/archive/2010/02/16/troubleshooting-subscriptions-part-ii-using-the-report-services-trace-log-file.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Java Dispatcher not coming up,Server node and SDM is running.

    Hi Everyone,
    While starting my Java instance, Dispatcher is stopped with return code "666",Server node and SDM is running.This is all of sudden not sure what has changed.
    I have changed the heap size value of dispatcher ,Did cleanipc ,But still no luck.
    My heap size parameters are according to SAP note:
    Note 0001024539 - Recommended Settings for NW04 >= SP14, NW 7.0 >= SP6 on AIX-BPBO.
    Java version :
    java version "1.4.2"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
    Classic VM (build 1.4.2, J2RE 1.4.2 IBM AIX 5L for PowerPC (64 bit JVM) build caix64142-20080923 (SR12) (JIT enabled: jitc))
    Please find below dispatcher error log.
    Mon Jan 10 15:36:04 2011
    JVMDUMP006I Processing Dump Event "systhrow", detail "java/lang/OutOfMemoryError" - Please Wait.
    JVMDUMP007I JVM Requesting System Dump using '/usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/core.20110110.153604.2523266.0001.dmp'
    Note: "Enable full CORE dump" in smit is set to FALSE and as a result there will be limited threading information in core file.
    Mon Jan 10 15:36:14 2011
    JVMDUMP010I System Dump written to /usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/core.20110110.153604.2523266.0001.dmp
    JVMDUMP007I JVM Requesting Snap Dump using '/usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/Snap.20110110.153604.2523266.0002.trc'
    JVMDUMP010I Snap Dump written to /usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/Snap.20110110.153604.2523266.0002.trc
    JVMDUMP007I JVM Requesting Heap Dump using '/usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/heapdump.20110110.153604.2523266.0003.phd'
    Mon Jan 10 15:36:15 2011
    JVMDUMP010I Heap Dump written to /usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/heapdump.20110110.153604.2523266.0003.phd
    JVMDUMP007I JVM Requesting Java Dump using '/usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/javacore.20110110.153604.2523266.0004.txt'
    JVMDUMP010I Java Dump written to /usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher/javacore.20110110.153604.2523266.0004.txt
    JVMDUMP013I Processed Dump Event "systhrow", detail "java/lang/OutOfMemoryError".
    </verbosegc>
    [Thr 6428] JLaunchIExitJava: exit hook is called (rc = 666)
    [Thr 6428] **********************************************************************
    ERROR => The Java VM terminated with a non-zero exit code.
    Please see SAP Note 943602 , section 'J2EE Engine exit codes'
    for additional information and trouble shooting.
    [Thr 6428] SigISetIgnoreAction : SIG_IGN for signal 20
    [Thr 6428] JLaunchCloseProgram: good bye (exitcode = 666)
    Could somebody help...
    Thanks

    Hi John ,Thanks
    The dispatcher connects to only one server node.dev_dispatcher content details below.
    JStartupIReadSection: read node properties [ID18122300]
    -> node name          : dispatcher
    -> node type          : dispatcher
    -> node execute       : yes
    -> jlaunch parameters :
    -> java path          : /usr/java14_64
    -> java parameters    : -Xmn70M -Xgcpolicy:gencon -verbose:gc -Xj9 -Xdump:system:events=systhrow,filter=java/lang/OutOfMemoryError,request=exclusive+prepwalk -Djava.security.policy=.\java.policy -Djava.security.egd=file:/dev/urandom -Djco.jarm=1
    -> java vm version    : J2RE 1.4.2 IBM J9 2.3 AIX ppc64-64 j9ap64142-20080923 (JIT enabled)
    -> java vm vendor     : IBM J9 VM (IBM Corporation)
    -> java vm type       : server
    -> java vm cpu        : ppc64
    -> heap size          : 200M
    -> init heap size     : 200M
    -> root path          : /usr/sap/D10/DVEBMGS01/j2ee/cluster/dispatcher
    -> class path         : ./bin/boot/boot.jar:./bin/system/bytecode.jar:.
    -> OS libs path       : /usr/sap/D10/DVEBMGS01/j2ee/os_libs
    -> main class         : com.sap.engine.boot.Start
    -> framework class    : com.sap.bc.proj.jstartup.JStartupFramework
    -> registr. class     : com.sap.bc.proj.jstartup.JStartupNatives
    -> framework path     : /usr/sap/D10/DVEBMGS01/exe/jstartup.jar:/usr/sap/D10/DVEBMGS01/exe/jvmx.jar
    -> shutdown class     : com.sap.engine.boot.Start
    -> parameters         :
    -> debuggable         : no
    -> debug mode         : no
    -> debug port         : 50000
    -> shutdown timeout   : 120000
    [Thr  1] JLaunchISetDebugMode: set debug mode [no]
    [Thr 772] JLaunchIStartFunc: Thread 772 started as Java VM thread.
    JHVM_LoadJavaVM: VM Arguments of node [dispatcher]
    -> stack   : 1048576 Bytes
    -> arg[  0]: exit
    -> arg[  1]: abort
    -> arg[  2]: vfprintf
    -> arg[  3]: -Xmn70M
    -> arg[  4]: -Xgcpolicy:gencon
    -> arg[  5]: -verbose:gc
    -> arg[  6]: -Xj9
    -> arg[  7]: -Xdump:system:events=systhrow,filter=java/lang/OutOfMemoryError,request=exclusive+prepwalk
    -> arg[  8]: -Djava.security.policy=.\java.policy
    -> arg[  9]: -Djava.security.egd=file:/dev/urandom
    -> arg[ 10]: -Djco.jarm=1
    -> arg[ 11]: -Dsys.global.dir=/usr/sap/D10/SYS/global
    -> arg[ 12]: -Dapplication.home=/usr/sap/D10/DVEBMGS01/exe
    -> arg[ 13]: -Djava.class.path=/usr/sap/D10/DVEBMGS01/exe/jstartup.jar:/usr/sap/D10/DVEBMGS01/exe/jvmx.jar:./bin/boot/boot.jar:./bin/system/bytecode.jar:.
    -> arg[ 14]: -Djava.library.path=/usr/java14_64/jre/bin:/usr/java14_64/jre/bin:/usr/java14_64/jre/bin/classic:/usr/java14_64/jre/bin:/usr/sap/D10/DVEBMGS01/exe:
    /usr/sap/D10/DVEBMGS01/exe:/usr/sap/D10/DVEBMGS01/exe:/usr/TDAccess2.4.1:/usr/sap/D10/SYS/exe/run:/oracle/client/10x_64/instantclient:/
    usr/java14_64/jre/bin/j9vm:/usr/sap/D10/DVEBMGS01/exe::/usr/lib:/usr/sap/D10/DVEBMGS01/j2ee/os_libs:/usr/sap/D10/DVEBMGS01/exe:/usr/sap/D10
    /DVEBMGS01/exe:/usr/sap/D10/DVEBMGS01/exe:/usr/TDAccess2.4.1:/usr/sap/D10/SYS/exe/run:/oracle/client/10x_64/instantclient
    -> arg[ 15]: -Dmemory.manager=200M
    -> arg[ 16]: -Xmx200M
    -> arg[ 17]: -Xms200M
    -> arg[ 18]: -DLoadBalanceRestricted=no
    -> arg[ 19]: -Djstartup.mode=JCONTROL
    -> arg[ 20]: -Djstartup.ownProcessId=2748598
    -> arg[ 21]: -Djstartup.ownHardwareId=U0234126406
    -> arg[ 22]: -Djstartup.whoami=dispatcher
    -> arg[ 23]: -Djstartup.debuggable=no
    -> arg[ 24]: -DSAPINFO=D10_01_dispatcher
    -> arg[ 25]: -DSAPSTART=1
    -> arg[ 26]: -DCONNECT_PORT=64999
    -> arg[ 27]: -DSAPSYSTEM=01
    -> arg[ 28]: -DSAPSYSTEMNAME=D10
    -> arg[ 29]: -DSAPMYNAME=eccdcs1s_D10_01
    -> arg[ 30]: -DSAPPROFILE=/usr/sap/D10/SYS/profile/D10_DVEBMGS01_xxxxxxx
    -> arg[ 31]: -DFRFC_FALLBACK=ON
    -> arg[ 32]: -DFRFC_FALLBACK_HOST=localhost
    -> arg[ 33]: -DSAPSTARTUP=1
    -> arg[ 34]: -DSAPSYSTEM=01
    -> arg[ 35]: -DSAPSYSTEMNAME=D10
    -> arg[ 36]: -DSAPMYNAME=xxxxxxxx_D10_01
    -> arg[ 37]: -DSAPDBHOST=xxxxxxx
    -> arg[ 38]: -Dj2ee.dbhost=xxxxxx
    Edited by: Khaiser Khan Mohammed on Jan 18, 2011 11:19 AM

  • Server Administrator has Limited the Number of Items You Can Open Simultaneously

    Over the weekend, we moved all of our room mailboxes over to Exchange. For users who have lots of room calendars open in their Outlook clients, they are getting the error message "Cannot Open the free/busy information. You Server Administrator has Limited
    the Number of Items You Can Open Simultaneously" after the migration from Exchange 2010.
    Restarting the Outlook client temporary fixes the problem, but the problem comes back after they access the calendars again.
    The users impacted deal with a lot of room scheduling, so they have 30+ room calendars open in their Outlook clients.
    I have tried setting up a throttling policy with unlimited RCA connections, but that didn't help.
    I have seen with Exchange 2010 there were some registry keys people were setting on the server that pretty much makes everybody have unlimited connections, but that isn't ideal if's only affecting a few people.

    Hi,
    Since this issue only occurs to a few users, I recommend you disable all the third-party applications on Windows, especially for the desktop search apps. Meanwhile, use Outlook safe mode to disable all the add-ins and check if the issue persists.
    If the issue persists, you need to reset the value of Maximum Allowed Sessions Per User. Besides, we can't set it for only some specified users.
    Here is a thread for your reference.
    Event 9646, MSExchangeIS - Mapi session exceeded the maximum (Note: Though it is Exchange 2010, it also applies to Exchange 2013 about this issue)
    https://social.technet.microsoft.com/Forums/exchange/en-US/91922b60-38b7-4af3-ba13-3b44949cc9f7/event-9646-msexchangeis-mapi-session-exceeded-the-maximum-exchange-2010-sp1-w-update-roll-up-2?forum=exchange2010
    Hope this can be helpful.
    Best regards,
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Amy Wang
    TechNet Community Support

  • Java threads and WinLogon processes taking CPU!

    We are seeing a strange problem. We have a multi-threaded java application
    that is deployed on a Microsoft Windows 2000 server (SP4) with Citrix
    Metaframe XP (Feature release 2). When this application starts, we start to see
    multiple WINLOGON.EXE processes (20 plus) each taking up 1-2% of CPU -
    this raises the CPU usage on the server significantly, impacting performance.
    We have tested with JDK 1.3, 1.4, and 1.5 and see the same issues. If we
    run the java application in a single thread, we dont see the same issue.
    Has any one seen this problem before? Any suggestion on how this can be resolved?
    Thanks in advance!

    Thanks for your replies. This is a Citrix environment where there are 50 plus
    users logged in and there are 50 plus instances of Winlogon.exe always
    running. Most of the time the cpu usage of these processes is 0.
    We tried a multi-threaded program that lists files in a directory every few
    seconds. There are 40 plus servers in the farm that we are deploying this
    application on. We are seeing this problem on only some of the servers.
    If we run a single thread from main(), we dont see the issue. But if we spawn
    10 threads doing the scans periodically, we notice that as soon as all the threads
    start, the WinLogons appear to start to take up CPU. When we stop the java
    program, the WinLogon processes drop in CPU usage.
    Is it possible that Java and WinLogon share some dlls that could be triggering
    the WinLogon processes off?
    We have tried running the single thread and multi-threaded programs around
    same time and the correlation with the winlogons is clearly visible. If we add
    sleep() soon after we start a thread, the winlogons seem to kick in later.

  • Handling Threads and Memory

    I'm sorry if this is a cross post to my StringBuffer problem. I have run a test that instantiates the object in question and the memory gets collected so I don't think it's that. My question is on how memory pertaining to Threads is handled.
    In my application I have a Thread array that launches X number of Threads. Currently 5. When an object wants a job run, the static Thread pool looks at the current thread and sees if it is still working. If it is, we sleep until it is available. Then I give it another job to do, start it, and move to the next thread.
    Question 1 -
    In a Thread [] is it better to replace the Thread at position x as in
    threads[a] = new Thread();
    threads[a].start();
    or is it better to change some parameter in the thread and then call
    start() again?
    Question 2 -
    I am currently using the second method. In my Thread object I have a MessageObject which contains a StringBuffer, which is eating memory. These MessageObject's are increasing. Some are being collected but many are staying live in the system and causing a memory error. When I do the following....
    MyThread.MessageObject = new MessageObject()
    That should make the original object available for cleanup right?
    Should I call finalize on the MessageObject before replacing it?
    Thanks you for any insights.

    If you want to use thread pools, and you can use JDK 5.0 (formerly known as J2SDK 1.5, codename Tiger), try using the java.util.concurrent package instead of writing your own thread pool (it's really difficult to make a thread pool right).
    If you can't use JDK 5.0, you can try the original util.concurrent package ( http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html ) from Doug Lea. It's used in the JBoss Application Server, so it's tested and reliable.
    If you need to use an object pool, try using the Commons Pool Component from Jakarta Apache: http://jakarta.apache.org/commons/pool/

  • Little bit of thread and little bit of instant messenger design problem

    OK! i have a small problem here, i am planning on making a instant messenger server and client, not compatible with any out there(as of yet) and not using any stansard protocols out there, just something i made on my own. ok now the problem i am trying to figure out is....i have a "Messaging Server" as the name suggests it sends messages from one client to the other, how it is setup is, client connects to this server, the server accepts and creates a new thread for this client and adds a message listener to this client handler thread. as and when the server creates this thread for the client, it puts it in a vector which is keeping track of every client connected to this server. so now when the client sends a message to another client, basically it goes through this server, the thread upon receiving this message, fires a method of the listener. this method takes the message, finds out who it is going to(therefore the userid) and seaches the threads vector to find the appropriate thread and then just creats another striped down message out of the received message and calls a method in that thread to send this newly created message and hence the message should be sent.(i am speculating, i still have not created this)
    so the problem ia m logically facing is...at what point of time who is taking the load, what i mean by that is, when the thread receives the message, ofcourse it is this thread which is working is taking the load, but when the listener fucntion is fired which thread is handlign the call is it the client handler thread which fired the method or the messaging server thread which creates these threads?? now once that is solved, who(which thread) is doing the work when i call the fucntion in the other thread which i found aftre searching the vector. i mean i am thinking like this cuz i am not much in sink with the way threads work. i am also trying to figure out this to find out the load the server or the threads will be having.
    algo example:
    class messageServer
         vector currentWorkingThreads;
         messageListener listener;
         main()
              listener = new messageListener(); //should it be here or the other place i am mentioning below
              while(true)
                   clientHandler = socket.accept();
                   listener = new messageListener(); //should it be here or the other place i am mentioning above
                   //create a thread and add this thread object to the vector
                   thread.addLisenter(listener);
    class messageServerThread
         string userid;
         messageListener lis;
         run()
              object obj = in.readObject();
              lis.sendMessage(obj);
         sendMessage(obj)
              out.writeObject(obj);
              out.flush;
    class messageListener
         sendMessage(msSendMessage msg)
              //find the appropriate user thread
              loop(currentWorkingThread.next())
                   messageServerThread msgThread = (messageServerThread)currentWorkingThread.element();
                   if(msg.userid == msgThread.userid)
                        msReceiveMessage rcvMsg = msg.strip(); //dosent matter what this does, it just strips the unwanted info and returns the type msReceiveMessage
                        msgThread.sendMessage(rcvMsg);
    and if this is something out of the line, or not a good way of doing it, can someone help me with the design it would be gr8.
    thanx a lot
    -Ankur
    help would be greatly appreciated.
    [email protected]

    other, how it is setup is, client connects to this
    server, the server accepts and creates a new thread
    for this client and adds a message listener to this
    client handler thread. as and when the server creates
    this thread for the client, it puts it in a vector
    which is keeping track of every client connected to
    this server.ok so far.
    so now when the client sends a message to
    another client, basically it goes through this server,
    the thread upon receiving this message, fires a method
    of the listener. this method takes the message, finds
    out who it is going to(therefore the userid) and
    seaches the threads vector to find the appropriate
    thread and then just creats another striped down
    message out of the received message and calls a method
    in that thread to send this newly created message andhere you seem to confuse the thread instance and the thread of execution. the thread invoking this method is still the event handling thread (i.e. the receiver thread of the socket). you do not need threads for delivering - this can be done by the receiving sockets' event handling threads. disadvantage: if processing of the message takes significant time then the socket is blocked and cannot process another message.
    solution: put the message in an event queue which is processed by one or more threads. (see my example i e-mailed you)
    robert
    hence the message should be sent.(i am speculating, i
    still have not created this)
    so the problem ia m logically facing is...at what
    point of time who is taking the load, what i mean by
    that is, when the thread receives the message,
    ofcourse it is this thread which is working is taking
    the load, but when the listener fucntion is fired
    which thread is handlign the call is it the client
    handler thread which fired the method or the messaging
    server thread which creates these threads?? now once
    that is solved, who(which thread) is doing the work
    when i call the fucntion in the other thread which i
    found aftre searching the vector. i mean i am thinking
    like this cuz i am not much in sink with the way
    threads work. i am also trying to figure out this to
    find out the load the server or the threads will be
    having.
    algo example:
    class messageServer
    vector currentWorkingThreads;
    messageListener listener;
    main()
    listener = new messageListener(); //should it be
    e here or the other place i am mentioning below
    while(true)
    clientHandler = socket.accept();
    listener = new messageListener(); //should it be
    be here or the other place i am mentioning above
    //create a thread and add this thread object to the
    he vector
    thread.addLisenter(listener);
    class messageServerThread
    string userid;
    messageListener lis;
    run()
    object obj = in.readObject();
    lis.sendMessage(obj);
    sendMessage(obj)
    out.writeObject(obj);
    out.flush;
    class messageListener
    sendMessage(msSendMessage msg)
    //find the appropriate user thread
    loop(currentWorkingThread.next())
    messageServerThread msgThread =
    =
    (messageServerThread)currentWorkingThread.element();
    if(msg.userid == msgThread.userid)
    msReceiveMessage rcvMsg = msg.strip(); //dosent
    ent matter what this does, it just strips the unwanted
    info and returns the type msReceiveMessage
    msgThread.sendMessage(rcvMsg);
    and if this is something out of the line, or not a
    good way of doing it, can someone help me with the
    design it would be gr8.
    thanx a lot
    -Ankur
    help would be greatly appreciated.
    [email protected]

  • Why did my server crash and what to do to prevent this?

    hi there,
    i've been following the installation guide on single host and all looked well until yesterday all of a sudden i couldn't see my mail tab when using webmail.
    i tried re-logging in several times and from three computers at home but no mail tab was dispayed (calendar, address book, etc were fine). in some occasions i have been displayed an error msg saying i should reconfigure the server.
    so i went on today to check the server but having a very limited knowledge of administration i couldn't figure out what to check and where so i stopped all services as advised in single host guide. notably web and messaging servers (or services?) weren't running. i restarted them and now require some help to diagnose why this all happened as i was not getting any emails until the server was restarted.
    i was able to log in yesterday morning however in the afternoon server has crashed. it didn't restart or hung up but web server wasn't running anymore. the last email i received was 3.21 pm yesterday. after i restarted all services today, a few emails were displayed immediately with current date and time (10 am today), however i don't know whether these were emails received while server was 'malfuntioning' or they are some left overs from last seconds of working.
    i remember myself running update service on the server yesterday and it looked okay today's morning when i found it finished updating the computer. could this be the reason? did update service stopped web server from running?
    also after i restarted the machine this morning i had to re-run all services all over again. don't they just start automatically upon reboot? what if power fails and my APC UPS shuts machine down and then boots it back when power regains?
    pls help me as i am new guy on the block and want to stick to Sun products but don't want to be put off by some mysterious errors and instability of such a great software package which CommSuite defintiely is.

    Graham_Brown wrote:
    i've been following the installation guide on single host and all looked well until yesterday all of a sudden i couldn't see my mail tab when using webmail.If you cannot see the mail-tab you need to verify whether the messaging server processes are running. It helps to have a high-level view of how things fit together:
    http://docs.sun.com/app/docs/doc/819-4440/6n6jfgch0?a=view
    In this case for the mail-tab to work you need messaging server running, specifically the mshttpd (webmail) process and the imapd (IMAP) process.
    i tried re-logging in several times and from three computers at home but no mail tab was dispayed (calendar, address book, etc were fine). in some occasions i have been displayed an error msg saying i should reconfigure the server.The error message advising to reconfigure the server is misleading. If this was the first time you accessed the comms-express interface and had no mail-tab then the message is pointing out that you may have misconfigured something (which was really easy to do in earlier releases). As you had already successfully accessed the mail-tab this is more indicating that something is now broken/not-running correctly.
    so i went on today to check the server but having a very limited knowledge of administration i couldn't figure out what to check and where so i stopped all services as advised in single host guide. notably web and messaging servers (or services?) weren't running. i restarted them and now require some help to diagnose why this all happened as i was not getting any emails until the server was restarted.Four things you can do at this juncture:
    1. Configure coreadm to capture any future core dumps (assuming of course the processes died abnormally e.g. coding issue, memory starvation ...) http://docs.sun.com/app/docs/doc/819-5355/6n7eo3v6v?a=view
    2. Enable auto-restart of processes. http://docs.sun.com/app/docs/doc/819-4428/bgadd?a=view
    3. Check patching levels and update to address known issues. http://www.sun.com/bigadmin/hubs/comms/downloads/updates.jsp#cp1
    4. Log a Sun Support Case to have the issue investigated (assuming you have a support contract). http://msg.wikidoc.info/index.php/Submit_sun_support_request
    i was able to log in yesterday morning however in the afternoon server has crashed. You need to be very specific about what actually 'crashed'.
    Saying the "server has crashed" implies that the entire system (at the hardware/OS level) crashed/rebooted.
    If the 'webserver' has crashed then you would be able to access the system via SSH (so the hardware/OS is working) but when you connect to the server using a webclient to get mail, you don't get a connection.
    If the 'mailserver' has crashed then you would be able to log into Comms Express or at least see the login page (webserver is working) but one or more components are not working (if you cannot login then chances are there are directory server issues, if there is no mail-tab then this is mail-server issues, no calendar tab, calendar-server issues, no address-book then potentially directory-server issues and so on).
    it didn't restart or hung up but web server wasn't running anymore. the last email i received was 3.21 pm yesterday. after i restarted all services today, a few emails were displayed immediately with current date and time (10 am today), however i don't know whether these were emails received while server was 'malfuntioning' or they are some left overs from last seconds of working.If you have enabled mail logging then you can see when the emails were being accepted.
    http://docs.sun.com/app/docs/doc/819-2650/6n4u4dtv9?a=view#bgbew
    i remember myself running update service on the server yesterday and it looked okay today's morning when i found it finished updating the computer. could this be the reason? did update service stopped web server from running?Which 'update service' are you referring to?
    also after i restarted the machine this morning i had to re-run all services all over again. don't they just start automatically upon reboot? what if power fails and my APC UPS shuts machine down and then boots it back when power regains?You need to configure the various components to start-on-boot using /etc/init.d/* scripts. This is a standard system-administration task.
    pls help me as i am new guy on the block and want to stick to Sun products but don't want to be put off by some mysterious errors and instability of such a great software package which CommSuite defintiely is.At this juncture I recommend that you investigate Solaris 10 administration training. The issues you have described aren't necessarily isolated to just CommSuite but are more standard system-admin tasks.
    Regards,
    Shane.

  • Exchange Server 2013 and Remote Access VPN on a single server running Windows Server 2012?

    Just by way of background, I have been installing and administering network servers, e-mail systems, VPN servers, and the like for many years.  However, my involvement with Exchange and Windows Server has been mostly on the forensics and data recovery
    level, or as a (sophisticated) user.  I have never tried to deploy either from scratch before.  My deployment experiences have been mostly with Linux in recent years, and with small private or personal "servers" running such cutting edge
    software as Windows XP back when it was new.  And even NetWare once.
    When a client asked me if I could set up a server for his business, running Exchange Server (since they really want Outlook with all of its bells and whistles to work, particularly calendars) and providing VPN access for a shared file store, I figured it
    could not be too difficult given that its a small business, with only a few users, and nothing sophisticated in the way of requirements.  For reasons that don't bear explaining here, he was not willing to use a vendor hosting Exchange services or cloud
    storage.  There is no internal network behind the server; it is intended to be a stand-alone server, hanging off a static IP address on the Internet, providing the entirely mobile work-force of about 10 people with Exchange-hosted e-mail for their computers
    and phones, a secure file store, and not much else.  If Exchange didn't need it, I would not need to install Active Directory, for example.  We have no direct need for its services.
    So I did the research and it appears, more by implication than outright assertion, that I should be able to run Windows Server 2012 with Exchange Server 2013 on a server that also hosts Remote Access (VPN only) and does nothing else.  And it appears
    I ought to be able to do it without virtualizing any of it.  However, I have spent the last three or four days fighting one mysterious issue after another.  I had Remote Access VPN working and fairly stable very quickly (although it takes a very
    long time to become available after the server boots), and it has mostly remained reliable throughout although at times while installing Exchange it seems to have dropped out on me.  But I've always been able to get it back after scrounging through the
    logs to find out what is bothering it.  I have occasionally, for a few minutes at a time, had Exchange Server willing to do everything it should do (although not always everything at the same time).  At one point I even received a number of e-mails
    on my BlackBerry that had been sent to my test account on the Exchange Server, and was able to send an e-mail from my BlackBerry to an outside account.
    But then Exchange Server just stopped.  There are messages stuck in the queues, among other issues, but the Exchange Administration Center refuses now to display anything (after I enter my Administrator password, I just get a blank screen, whether on
    the server or remotely).
    So, I am trying to avoid bothering all of you any more than I have to, but let me just begin with the basic question posed in the title: Can I run Exchange Server (and therefore Active Directory and all of its components) and Remote Access (VPN only) on
    a single Windows Server 2012 server?  And if so, do I have to run virtual machines (which will require adding more memory to the server, since I did not plan for it when I purchased it)?  If it can be done, can anyone provide any pointers on what
    the pitfalls are that may be causing my problems?  I am happy to provide whatever additional information anyone might like to help figure it out.
    Thanks!

    An old thread but I ran into this issue and thought I share my solution since I ran into the same issue. Configuring VPN removes the HTTPS 443 binding on the Default Site in IIS for some strange reason; just go and editing the bindings, add HTTPS and things
    should be back to normal.

  • TS1490 i am running Windows Home Server 2011 and iTunes can't seem to connect to the iTunes Store nor run Genius on my Library.  What do I need to do?

    I am running Windows Home Server 2011 and have installed iTunes on my dedicated server, attached to my router.  I can't connect to the iTunes Store nor run Genius on the server ONLY (iTunes runs fine on by two other PCs and my Apple TV and I share the libary that resides on the server).  I am running a very current version of iTunes 64 bit.  I have run the connectivity test and it failed. 
    My guess is that there is some setting in the Server software that i need to change to let iTunes access urls or computers on the internet.  Does anyone have any experience with this software combination?
    Thank you

    Some guy managed to get this to work. The following link is for iTunes 10.5 but it should work for the current release.
    http://social.microsoft.com/Forums/en-US/whs2011/thread/bd62ee3d-a933-4cad-ae9b- fd38adc994c0
    Good luck!

  • Small business server 2003 and database 2008 r2

    Hello,
    I already use at work small business server 2003 and I would like to install sql serwer 2008 r2 express. And my questions is. Is there any possibility to install sql server 2008 express on small business server 2003 ? My database has a limitation of size
    to 4 gb. When i trying to add a new business contact in BCM i get a massage: could not allocate space for object in database because the 'primary' filegroup is full. i am very much appreciate for  help.

    You can install SQL express on SBS 2003.
    Maybe you can use het comments in
    this link.

Maybe you are looking for

  • ICal One-Way Sync? (iPhone to Mac)

    So, the other day my mother accidentally erased all of her events in iCal on her Mac. She still had them all on her iPhone, so she tried to sync it with her Mac to undo the deletions. But it did the opposite; all of her events were lost on her phone.

  • All mail being sent from default account!!!!

    Hello. I have four (4) email accounts linked to my iPhone. Whenever I send a message from any account, it sends it from the default account. Is there a way to fix this? I'll try to explain in better like this ... - My default account is #1 of 4 - I w

  • Some photos were not uploaded to Photostream

    Photos taken yesterday evening were not uploaded to Photostream. Automatic upload seems to have resumed today, but only the pictures I took today. Is there a way I can get last year's photos uploaded to Photostream without importing them to a compute

  • Can somebody please help me recover my music??

    ok, so my story is this. My hardrive on my computer failed and I sent it in to be replaced for a new one. It came back and now I had to download the i-pod software again. I connected my ipod to the computer and then it asked me a question and I thogh

  • Reset the phone to factory settings or wait???????

    Hi.......Have a 3gs with a problem....since i upgraded to ios4 my gps wont work any more. What do you think...should i wait for the fix (4.1) or blow the phone clean and set it back to factory settings??