How to get  ServerSocket to tell client that it's not accepting?

I've had a couple of other topics recently, concerning my attempt to write a client/server TicTacToe game for my final project in Data Comm. I've got almost all of what I want worked out this week, but I'm stumped on this one. The project spec includes some way of controlling access to the application on the server -- do some work on figuring out the limits of the resources, and set up a way to limit the number of clients that can connect at one time.
I thought that for my purposes, for proof of concept, I would set it up so that up to 3 clients could play at one time, and up to 2 could be allowed to "connect, but wait for a turn" until someone playing logged off. Conceptually I can draw a flow chart of it, but what I can't figure is this -- I have a server object that accepts connections with ServerSocket.accept(), and sends off the socket created as an argument to a new thread of the ServerGame class. ServerGame has a static int for threadcount. I can code in ServerGame to limit it to 3 who can actively be allowed to play, and send a message back to someone who connects later to say, "Wait", and in the Server itself I can refuse to accept() if a 6th client tries to connect, but for that 6th client -- how can I get a message saying "You can't even connect now -- no room even in the queue"? If the server doesn't even accept(), what's the means of response, other than the poor client sitting there with an unresponsive button in his GUI? That's what happens now -- the first client that tries to connect when the server won't accept, his GUI just freezes. Not a good interface.
Unfortunately this is a Data Comm class, and the teacher is new this year and comes from 25 years in industry and knows C/C++, but no java.

My puzzlement is that I'm a beginner ( we just got introduced to the idea of sockets in class a month ago, and I chose java not only because I like it best but golly, the socket API in C and C++ is awful compared to java).
My understanding of ServerSocket is that it does not make a connection that it can use itself, but passes off to something or someone. My model is to have a ServerGame class, threaded so the Server spawns a new thread of ServerGame for each new socket and passes the socket to the constructor of the new ServerGame thread. The it goes off and does its thing.
So I don't understand what you mean by setting a flag (I understand flags, just not what the idea is in this case). And how can I call a function on a server on a different machine? Chicken and egg -- how can I communicate if I can't connect, and if I do connect the connection is sent off to the ServerGame, not the Server itself.
Wait -- just thought of something -- is this what you mean? If I set a condition that recognizes I've reached the limit, ServerSocket could create a connection but NOT send it to the ServerGame, but to a temporary object of some kind, that just sends back a message and closes and dies?
Sounds do-able, but time's up, I gotta get to school. I'll check in later
Thanks a lot
F

Similar Messages

  • How to get the ip of client that is using the server?

    I am doing a FTP like system using Java. I would like to get the time and the IP of the client that want to download the files from the system. Does anyone know the method to do so?

    If you're using plain sockets you may call socket's getInetAddress() or if you're using jsp / servlets you may call request.getRemoteAddr()

  • The techs wiped my computer and now I can not get iPhoto it tells me my computer can not accept this application. How do I get iPhoto so I can transfer my backed up photos

    How do I get Iphoto. After resetting up my computer and trying ot manually transfer my iphoto library the app store says I can not accept this application on this computer. How can I get it back?

    Contact the Techs and get them to sort out this account issue.
    Regards
    TD

  • I have just won an iphone 3gs in a raffle but when i put in my sim it tells me that it is not supported how can i get the iphone to work

    I have just won an iphone 3gs in a raffle but when i put in my sim it tells me that it is not supported how can i get the iphone to work?

    In that case the procedure assuming it is a PAYG phone is to get an o2 PAYG sim, put £20 on it and then make a few calls making sure you leave £15 on the sim to pay for the unlock. Then there is an online unlock request form on the o2 site just fill this in. It takes between 1-14 days and you get a message from o2 telling you how to complete the official unlock through iTunes.
    I got my o2 unlock in nov 09 so this is not just opinion.

  • I am trying to install windows 7 on my macbook pro 13", when i run bootcamp it tells me that there is not a windows support software available for my computer. Where can i get the windows support software for my macbook?

    I am trying to install windows 7 on my macbook pro 13", when i run bootcamp it tells me that there is not a windows support software available for my computer. Where can i get the windows support software for my macbook?

    Apple only supports Windows on certain hardware.
    http://www.apple.com/support/bootcamp/
    Apple provides their framework for Windows to run on a Mac, a piece of software called a Hybrid MBR that bridges the gap between how Windows reads the drive partition table (MBR) and EFI/GUID partition table that Mac's use.
    It doesn't mean Windows can't run on your Mac, a third party solution called rEFIt will also bridge the gap and allow booting of more that just Windows, Linux as well for a triple booting computer.
    Your hardware has to meet the other requirements the second and third operating system needs as as being able to install drivers that will work for your hardware, especially the fans or they will run loud and fast by default.
    http://refit.sourceforge.net/
    This above is a advanced procedure which requires knowledge how computers and various operating systems, drive formats and so forth work.
    I even admit I don't know everything myself, but I experiment on a separate piece of Mac hardware (out of warranty/AppleCare) designed for this purpose so in case something screws up I'm not taking down my only machine and can use the other to get online and find solutions.
    There is a very high potential for losing your data if your using advanced/non-Apple methods to install Windows on your only Mac where Apple doesn't support it. Also one shouldn't be doing this on Mac hardware that is under AppleCare or warranty as it might be voided. Proceed at your own risk and education.

  • HT5625 My daughter and I were both on same Apple ID. We are trying to change hers but when we do, it says her email is already associated with an Apple ID but when we try to get the password, it says that it could not be verified. How do we correct this?

    My daughter and I were both on same Apple ID. We are trying to change hers but when we do, it says her email is already associated with an Apple ID but when we try to get the password, it says that it could not be verified. How do we correct this?

    Not from your end. Click here and ask the iTunes Store staff for assistance.
    (126716)

  • I can not sync my iPhone to the computer. I keep getting up an error message that synchronization does not want to start. I have uninstalled iTunes and then reinstall it. But the same warning box will appear. How can I get my phone in sync again?

    Can someone please help me get my iPhone to sync to your computer?
    I can not sync my iPhone to the computer. I keep getting up an error message that synchronization does not want to start. I have uninstalled iTunes and then reinstall it. But the same warning box will appear. How can I get my phone in sync again?

    Hello lenmin,
    Thanks for using Apple Support Communities.
    To help resolve this issue where you're repeatedly prompted to authorize with your Apple ID in iTunes when syncing, please follow the directions in the article below.
    iTunes: Missing folder or incorrect permissions may prevent authorization - Apple Support
    Have a great weekend,
    Alex H.

  • I just purchase an IPhone5C to upgrade from my IPhone4, but I do not know how to get all of my photos that were on ICloud on my Photo Stream (875 photos), on to my new phone. I thought that since my 5C can see Icloud that all photos would be there...

    I just purchase an IPhone5C to upgrade from my IPhone4, but I do not know how to get all of my photos that were on ICloud on my Photo Stream (875 photos), on to my new phone. I thought that since my 5C can see Icloud that all photos would be there... Can someone help me get the pics from my Iphone4 to the 5C?

    Photostream in the cloud only keeps photos from the last 30 days (subject to a 1,000 photo limit). When photostream syncs the photos to your device they will stay there (subject to a 1,000 photo limit) until deleted, which means you may well have more photos in your photostream album on your device than there are in photostream in the cloud.
    The consequence of this is that if you turn photostream off and on again on your device (or enable it for the first time), it will only be populated with photos from the last 30 days, which may not be all the photos that were previously in the photostream album on that device.

  • HOW TO GET INFORMATION ABOUT THE CLIENT MACHINE AT DATABASE LEVEL

    HOW TO GET INFORMATION ABOUT THE CLIENT MACHINE AT DATABASE LEVEL USING 10g Database and 10g Application Server
    we have developed an application using oracle forms 10g with
    oracle database 10g and Application server 10g
    Application uses a single Oracle User name to connect to database
    where as at Application level there are different users (these are not database users)
    Now how can we get the information about the user/his machine etc. at database level. earlier in 6i/8i we use to get by using
    USERENV('TERMINAL')
    we had written a triggers on tables on Insert/Update where we used to update a database field Last user terminal with USERENV('TERMINAL')
    but not this information is comming to be the machine name of application server where as we wish this to be the machine name of Client. Any Way outs
    thanks
    Chaand Kackria

    hi, you can use the sys_context function, like this:
    select sys_context('userenv','current_user'),
         sys_context('userenv','os_user'),
         sys_context('userenv','host'),
         sys_context('userenv','ip_address'),
         sys_context('userenv','instance'),
         sys_context('userenv','sessionid'),
         sys_context('userenv','terminal')
    from dual;
    Is this what you 're looking for?

  • I have an iPhone 5S, with iOS 8.1.2  I am trying to do a system restore but the message I get on the desktop is that there is not enough room on the iPhone. How much room is required?

    I have an iPhone 5S, with iOS 8.1.2  I am trying to do a system restore but the message I get on the desktop is that there is not enough room on the iPhone. How much room is required?
    I had an important app. (Memos by bluemarblesoftware.com) that I accidentally deleted. It of course had many memos, some with quite a lot of information. I did sync my phone on a regular basis and I think the memos should be on the desktop computer. I tried to do a restore function but I got a message saying there was not enough room on the iPhone. How much room is needed?

    generally you need 1.90gb
    what you can do is back up your phone to your computer before doing the update, just as a precaution.

  • Hey guyz.. i wanna ask if i get an updated version from itunes when i plug my iPhone into the Pc, i get a letter tells me that there is an update for your iPhone ... i wanna ask is it safe to download ?? and does it make any side effects on longTerm using

    hey guyz.. i wanna ask if i get an updated version from itunes when i plug my iPhone into the Pc, i get a letter tells me that there is an update for your iPhone ... i wanna ask is it safe to download ?? and does it make any side effects on longTerm using ??

    It is safe to download if your phone is not jailbroken. Before you download it, however, take some precautions:
    Reboot your computer
    Disable your antivirus and firewall
    Connect the phone cable to a USB port directly on the computer, not a hub
    Before updating right click on the name of the phone in iTunes and choose "Backup"
    When you are given the choice choose "Download only", not "Download and Update"
    After the download completes successfully click the Update button to install it.
    Most of these steps are just being overly cautious, as most people ignore them and have no problems. But occasionally the extra steps save grief.

  • How do I get Application Manager to recognize that Photoshop is not installed?

    Application Manager says that Photoshop CS6 is installed. It isn't. I've rebooted the Mac and it still says it's installed.  What installed was a partial or corrupt file which I have trashed. How do I get Application Manager to recognize that Photoshop is not installed so I can download and install it again?  Thanks.

    Do you have an uninstaller available to you in the Applications/Utilities/Adobe Installers folder?  If so then please run the uninstaller.
    If you don't then please utilize the uninstallers available in this folder to remove all currently installed Adobe Creative Software.  You will then want to follow this by running the CS Cleaner tool.  You can find details on the use of the CS Cleaner tool at CS Cleaner Tool for installation problems | CCM, CS6, CS5.5, CS5, CS4, CS3 - http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html.

  • How to get handle of a button that i created through Customisation?

    How to get handle of a button that i created through Customisation?
    I tried this in processformrequest ..failed :(
    String str2 = paramOAPageContext.getParameter("AutoDialler");
    if (str2 != null) {
    System.out.println("Inside AutoDialler Hurray");
    }

    this works well
    but can you give documentation support of whatever you are saying?
    public void processRequest(OAPageContext paramOAPageContext, OAWebBean paramOAWebBean)
    OASubmitButtonBean oasb= (OASubmitButtonBean)paramOAPageContext.getWebBeanFactory().createWebBean(paramOAPageContext,"BUTTON_SUBMIT");
    oasb.setID("xxSubmitAutoDialler");
    oasb.setUINodeName("xxSubmitAutoDialler");
    oasb.setEvent("xxSubmitAutoDialler");
    oasb.setText("xxSubmitAutoDialler");
    paramOAWebBean.addIndexedChild(oasb);
    public void processFormRequest(OAPageContext paramOAPageContext, OAWebBean paramOAWebBean)
    if ( strEvent.equals("xxSubmitAutoDialler"))
    //IMPORTANT Get this by calling the Function that loops for records.
    System.out.println("Inside processFormRequest Hurray");
    }

  • How to get a list of Apps that can not be recovered?

    After restoring a backup (iCloud), about 5% of my 225 were not restored because they did not appear over the Apple Store. How to get a list of Apps that can not be recovered?

    You should be able to download any apps that are missing at no extra cost. Just go to the App Store and download them again.

  • How to get a list of schemas that contain objects

    Hello,
    Kindly check on how to get a list of schema that contain objects.
    Regards,
    Tarman.

    Here is the oracle version info and it run under HP-UX.
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
    With the Partitioning and Real Application Clusters options
    JServer Release 9.2.0.5.0 - Production
    I have problem when run the query,
    SQL> select owner, count(object_name) from dba_objects where owner is not in ('S
    YS','SYSTEM','SYSMAN');
    select owner, count(object_name) from dba_objects where owner is not in ('SYS','
    SYSTEM','SYSMAN')
    ERROR at line 1:
    ORA-00908: missing NULL keyword
    Thanks.

Maybe you are looking for

  • Can I get Apple Store's e-mail address for customers?

    Can I get Apple Store's e-mail address for customers? My ipad mini with Retina has been delivered to wrong address.

  • Problem with Select query fetching records.

    Hi All, SELECT bukrs belnr gjahr bldat cpudt aedat cputm usnam xblnr bktxt waers                    FROM bkpf INTO TABLE bkpf_tbl                    WHERE bukrs IN s_bukrs AND blart IN ('RE' , 'ZL') AND ( ( cpudt > prv_date )                    OR   

  • Substitutions in MIRO transaction

    Hi everyone, I have a requirement where it needs to perform some substitutions in MIRO / MIR6 transactions, at save event. It must to make some substitutions on debit notes when it makes an INVOICE REDUCTION. The substitutions should be done in the f

  • Setting repaint behavior

    Hello I am now developing a swing application for my customer (which should work under windows and under MacOS X), and I have an issue to fix: When the main frame of my application is resized by pulling one of its borders with a mouse, the Swing trie

  • TEM: Relationship between External Person and Business Event

    Hi, The requirment is to have External Person to be related to Business Events. Please let me know whether it will be ideal to relate External Person to Business Events or External Person to Business Event Type? NOTE:As per the standard the relations