Want client to communicate with server

I am making a client/server application with the client being an applet and the server a program. The program is for a fictional chinese restaurant where the user selected a dish (using four radio buttons) and depending on the radio button selected, four ingrediants show as check boxes(their value also changes depending on the radio button selected).
I want the client to inform the server which radio button and check boxes have been selected so that the server can return the different ingrediants and their values in addition to working out the total price for the ingrediants selected. The problem is, I am unsure as to how to achieve this. Here is my code, I know it has problems, but i think it is generally OK:
client code:
import java.io.*;
import java.net.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AppletClientClass extends Applet implements
ActionListener {
     radPanel = new Panel();
     chePanel = new Panel();
     radio = new CheckboxGroup();
     radioOne = new Checkbox("Set Dinner A", false, radio);
     radPanel.add(radioOne);
     radioOne.addItemListener(this);
     radioTwo = new Checkbox("Set Dinner B", false, radio);
     radPanel.add(radioTwo);
     radioTwo.addItemListener(this);
     radioThree = new Checkbox("Set Dinner C", false, radio);
     radPanel.add(radioThree);
     radioThree.addItemListener(this);
     radioFour = new Checkbox("Set Dinner D", false, radio);
     radPanel.add(radioFour);
     radioFour.addItemListener(this);
     checkOne = new Checkbox(" ");
     chePanel.add(checkOne);
     checkOne.addItemListener(this);
     checkTwo = new Checkbox("ingre. 2");
     chePanel.add(checkTwo);
     checkTwo.addItemListener(this);
     checkThree = new Checkbox("ingre. 2");
     chePanel.add(checkThree);
     checkThree.addItemListener(this);
     checkFour = new Checkbox("ingre. 2");
     chePanel.add(checkFour);
     checkFour.addItemListener(this);
     checkFive = new Checkbox("ingre. 2");
     chePanel.add(checkFive);
     checkFive.addItemListener(this);
     txtField = new TextField (40);
     add(txtField);
     add(radPanel);
     add(chePanel);
     public void actionPerformed (ActionEvent ev) {
     try
Socket cts = new
Socket(getCodeBase().getHost(), 6000);
     DataInputStream isfs = new
DataInputStream(cts.getInputStream());
     DataOutputStream osts = new
DataOutputStream(cts.getOutputStream());
          osts.writeDouble(Double.parseDouble(unknown));//want this line to tell the server which buttons have been selected
     osts.flush();
     double input = isfs.readDouble(sum);
          txtField.setText("�" + String.valueOf(sum));
} catch (IOException ex) {
               System.out.println(ex);
Server code:
import java.io.*;
import java.net.*;
import java.awt.*;
public class AppletServerClass {
     public static void main(String[] args) {
          try
               ServerSocket ss = new ServerSocket(6000);
               Socket ctc = ss.accept(); // ctc = connect to client
               DataInputStream isfc = new DataInputStream(ctc.getInputStream()); // isfc = input stream from client
               DataOutputStream ostc = new DataOutputStream(ctc.getOutputStream()); // output stream to client
               double input = isfc.readDouble();
          double sum = 0;
          double ingre1 = 0;
          double ingre2 = 0;
          double ingre3 = 0;
          double ingre4 = 0;
          double ingre5 = 0;
          double totalIngre1 = 0;
          double totalIngre2 = 0;
          double totalIngre3 = 0;
          double totalIngre4 = 0;
          double totalIngre5 = 0;
          if(radioOne.getState() == true) // prices and ingredients if radio button one is selected
               ingre1 = 3.5;
               ingre2 = 6;
               ingre3 = 9;
               ingre4 = 12;
               ingre5 = 7;
               checkOne.setLabel("CurrySauce");
               checkTwo.setLabel("Egg Fried Rice");
               checkThree.setLabel("Chicken Chow Mein");
               checkFour.setLabel("Prawn Crackers");
               checkFive.setLabel("Meatballs");
          if (radioTwo.getState() == true) // prices and ingredients if radio button two is selected
               ingre1 = 5;
               ingre2 = 4;
               ingre3 = 7;
               ingre4 = 8;
               ingre5 = 2;
               checkOne.setLabel("Chips");
               checkTwo.setLabel("Egg Fried Rice");
               checkThree.setLabel("Chicken Chop Suey");
               checkFour.setLabel("Fried Duck");
               checkFive.setLabel("Omelette");
          if (radioThree.getState() == true)// prices and ingredients if radio button three is selected
               ingre1 = 4;
               ingre2 = 5;
               ingre3 = 8;
               ingre4 = 9;
               ingre5 = 8;
               checkOne.setLabel("Chicken");
               checkTwo.setLabel("Curry");
               checkThree.setLabel("Cod");
               checkFour.setLabel("Noodles");
               checkFive.setLabel("Meatballs");
          if (radioFour.getState() == true)// prices and ingredients if radio button four is selected
               ingre1 = 4;
               ingre2 = 3;
               ingre3 = 6;
               ingre4 = 2;
               ingre5 = 4;
               checkOne.setLabel("Roast Duck");
               checkTwo.setLabel("Noodles");
               checkThree.setLabel("Fried Squid");
               checkFour.setLabel("Soup");
               checkFive.setLabel("Fish");
          if (checkOne.getState() == true)
               totalIngre1 = ingre1;
          if (checkTwo.getState() == true)
               totalIngre2 = ingre2;
          if (checkThree.getState() == true)
               totalIngre3 = ingre3;
          if (checkFour.getState() == true)
               totalIngre4 = ingre4;
          if (checkFive.getState() == true)
               totalIngre5 = ingre5;
               sum = totalIngre1 + totalIngre2 + totalIngre3 + totalIngre4 + totalIngre5;
               ostc.writeDouble(sum);
               ostc.flush();
               System.out.println("The total price for this meal is " + sum);
          } catch (IOException e) {
               System.out.println(e);

I've not looked over your code extrememly closely, but it looks like you might be mixing client and server responsibilities. In your client you need to have all the code that deals with the UI. There shouldn't be any mention of labels or check boxes in the server code. You might want the flow to be:
Client:
Presents a series of radio buttons for meal possibilities
Queries the server for a list of ingredients for a selected meal
Displays a meal-sensitive list of ingredients
Submits the order to the server
Server
Accepts a request for a meal ingredient list
Responds with the ingredient list
Accepts an order
responds with a total
Then you need to work out how the client sends the meal possibility to the server, your current scheme of a double works, but it's easier (IMO) to use a String as a generic parameter type to move things back and forth with - that way you are always dealing with Strings. And you need to work out how the server sends an ingredient list to the client - you could use a delimited String and tokenize it. And then you need to work out how the client submits a finished order to the server, maybe a String that says "ORDER_COMPLETE" or something, with a delimited list of ingredients and the meal key.
I hope that made sense, and good luck
Lee

Similar Messages

  • Ways to Configure Which UNIX Server a PC Client Application Communicates With

    We have several different MS VC++ "fat client" applications that we want to run
    on the same NT 4.0 PC.
    Each application uses the Tuxedo 7.1 client to communicate with Tuxedo services
    located on a UNIX server.
    Each application needs to communicate with a different UNIX server (e.g., application
    A1 needs Tuxedo
    service T1 located on UNIX server S1, application A2 needs Tuxedo service T2 located
    on UNIX server
    S2). We'd like to load the Tuxedo 7.1 client software in such a way that each
    individual application
    controls which server it uses. One way to do that is through registry entries
    specific to each application.
    We are looking for some documentation or tips on other/better ways to configure
    which server the PC
    application communicates with. We are also looking for some documentation or
    tips on how to best
    configure an application that needs to subscribe to services from several different
    servers (e.g.,
    application A needs Tuxedo service T1 on server S1 and Tuxedo service T2 on server
    S2). Thanks.

    Matt,
    This sounds quite unusual, and I am not sure why you want to do things this way.
    Generally, I would expect that the services would be distributed on the server side over
    different boxes as you describe, but the location would be transparent to a client app.
    which would tpinit once, and Tuxedo would route the requests appropriately. Maybe that's
    not how you want to do things because the apps are all logically independent? I'm not
    sure about that though, since you describe needing services on different servers in
    individual clients... Can you do the integration at the back end?
    To do what you describe, however, you need to control the value of the WSNADDR
    environment variable before you call tpinit() - it is the network address in this
    variable that tells the client libraries which server to connect to. Simply set the
    value (from a command line parameter, the registry, an ini file or wherever) with the
    tuxputenv() API before you call tpinit()
    In Tuxedo 7.1 and higher, it is also possible to connect to multiple different servers
    simultaneousy by calling tpinit multiple times and having multiple contexts in the
    client.
    I hope that helps.
    Regards,
    Peter.
    Got a Question? Ask BEA at http://askbea.bea.com
    The views expressed in this posting are solely those of the author, and BEA
    Systems, Inc. does not endorse any of these views.
    BEA Systems, Inc. is not responsible for the accuracy or completeness of the
    information provided
    and assumes no duty to correct, expand upon, delete or update any of the
    information contained in this posting.
    Matt wrote:
    We have several different MS VC++ "fat client" applications that we want to run
    on the same NT 4.0 PC.
    Each application uses the Tuxedo 7.1 client to communicate with Tuxedo services
    located on a UNIX server.
    Each application needs to communicate with a different UNIX server (e.g., application
    A1 needs Tuxedo
    service T1 located on UNIX server S1, application A2 needs Tuxedo service T2 located
    on UNIX server
    S2). We'd like to load the Tuxedo 7.1 client software in such a way that each
    individual application
    controls which server it uses. One way to do that is through registry entries
    specific to each application.
    We are looking for some documentation or tips on other/better ways to configure
    which server the PC
    application communicates with. We are also looking for some documentation or
    tips on how to best
    configure an application that needs to subscribe to services from several different
    servers (e.g.,
    application A needs Tuxedo service T1 on server S1 and Tuxedo service T2 on server
    S2). Thanks.

  • How JavaFX can communicate with server?

    What is about communications with server from my JavaFX applet? Nowhere here found any of turorial or info how to support this thing. I need to develope web application, where my javaFX web app will not only makes different animations but should communicate with server very much. What approach to use in this case? Will we see here good example of how this could be managed?For now I see only client side stand-alone application.

    There are examples of JavaFX programs using Web services in the mentioned samples. For example [LocalSearch: Location-Based Coffee Shop Search With Yahoo Webservices|http://www.javafx.com/samples/LocalSearch/index.html], [Shopping Service: Accessing Yahoo's Shopping API from JavaFX|http://www.javafx.com/samples/ShoppingService/index.html], [Weather Widget: Getting Weather Forecast from Yahoo!|http://www.javafx.com/samples/WeatherWidget/index.html], and some others.

  • Last Contact with Server - Client Quit Communicating with Server

    Hi,
    Is there anyone with the same problem we're experiencing below?
    6 Windows 7 clients and 1 Windows XP client (10.2.2)
    All 6 Windows 7 clients quit communicating with the server after a while.
    Last contact with server time stamp doesn't change on both the client and
    server. Next contact with server does, but the client doesn't refresh. If I
    try to remote control, I can't. If I assign a new bundle, it doesn't work.
    However, I can login to the Zen agent.
    I can unregister the client locally and reregister and the client will
    communicate with the server for a while and it will then stop communicating
    again after several hours or couple days.
    All but the sole Windows XP client are having this issue. Windows XP client
    is also the first client registered in the server.
    thanks

    JS,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • HT1430 I am getting a message asking me to enter my Facebook password in the Settings. However, when I enter it, I get the message "unable to communicate with server." It's driving me crazy!

    I can't connect with the Facebook server. When I tried to connect with Facebook when playing Candy Crush, I got the message to "enter password for "" in Settings.  When I go to Settings, it says "There was a problem accessing your account. Please reenter the password for [my name]." Then, when I type in my password, I get the message "unable to communicate with server." 
    I tried deleting my Facebook account and then reinstalling it, but the problem continues. Any ideas?

    Dear Tomarshe
    I had the same problem a couple of weeks back.
    What I did was that I restarted that Ipad of mine and voila!
    Problem solved!
    hope this helped!
    - DASHdotDASHdot

  • I'm trying to set up my new iPhone 5s from a backup of my previous iPhone, when trying to enter my Facebook login info in settings I keep getting the following error message : error signing in could not communicate with server, please help !

    I'm trying to set up my new iPhone 5s from a backup of my previous iPhone, when trying to enter my Facebook login info in settings I keep getting the following error message : error signing in could not communicate with server, please help !

    Can you access other apps? Can you acess the internet? Can you access applications that use internet besides facebook?
    If answer is yes to all of these; contact Facebook.

  • I can't sign into my Facebook account on my ipad2 it says go to settings and sign in but when I do it says cannot communicate with server anyone able to help please

    I can't sign into my Facebook account on my ipad2 it says go to settings and sign in but when I do it says cannot communicate with server anyone able to help please

    Here is a solution that worked for me, after nothing else would. Log out and back in to iTunes on your Mac/PC.
    I had exactly the same problems as above, and no amount of network changes or even a full restore would help.
    Finally, I went back to my PC, launched iTunes, logged OUT of that, then signed in again, this time with the new password.
    Then I had to go back, and properly close Facetime and iMessages and sign in. It worked fine after that.
    (To properly close an application, double click the home button, then hold down on the facetime app logo in the multitasking bar at the bottom, then press the tiny symbol.)
    Best of luck.

  • HELP, i am unable to get Facebook to run.  I keep getting the following error:  Error signing in, unable to communicate with server.

    HELP, i am unable to get Facebook to run.  I keep getting the following error:  Error signing in, unable to communicate with server.

    >tutorial on learning PE
    Here are some links I've saved
    Saving & Sharing http://forums.adobe.com/thread/1051093
    Steve's Basic Training Tutorials... steps are the same for several versions
    -http://forums.adobe.com/thread/537685
    -v10 http://www.amazon.com/Muvipix-com-Guide-Premiere-Elements-Version/dp/1466286377/
    -All http://www.amazon.com/Tricks-Adobe-Premiere-Elements-Muvipix-com/dp/1451529724/
    -and http://forums.adobe.com/thread/498626
    -and http://prodesigntools.com/five-hours-free-tutorials-photoshop-and-premiere-elements-7-and- 8.html
    FAQ http://forums.adobe.com/community/premiere_elements/premiere_elements_faq
    TIPS http://forums.adobe.com/community/premiere_elements/premiere_elements_tips
    Another help site http://muvipix.com/ or http://muvipix.com/phpBB3/
    User Guide PDF http://help.adobe.com/en_US/premiereelements/using/index.html
    Right click PDF link in the upper right corner and select to save to your hard drive
    -the page also has links to help pages for previous versions

  • "Unable to communicate with server error" when pasting data in in list via edit

    Hi Guys, I imported data into a SharePoint site and it seems that it made the fields in to multiline, so I had to edit each colum and make it single, but when I did that it seems that the html font code also detached and views in the record as you can see.
    So I went into edit list so I can copy and past the same data back in without having the font color html code in, but once I did that I am getting a error which isn't letting me save
    Does anyone know how to pass this error or another way to remove all these font codes in my fields names?
    Thank you.

    Hi,
    For your issue, try to do IIS Reset, compare the results.                       
    You can use compatibility mode to check whether it works.
    Open IE->Tools->Compatibility View Settings
    You can also use Internet Explorer 8,9,10 to check whether it works.
    Also, please check the SharePoint ULS log located at : C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS to get a detailed error description.
    meanwhile check the following, may help:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/8142d297-d8f7-4b7a-8faa-052ecb9ae74a/custom-item-updating-throws-unable-to-communicate-with-the-server-error?forum=sharepointgeneral
    http://sharepoint.stackexchange.com/questions/94087/give-users-edit-permission-to-a-list-but-no-access-to-the-site
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/d7845547-e0f1-40de-badd-c66a34c0cfb4/the-server-was-unable-to-save-the-form-at-this-time-please-try-again
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • IOS6 upgrade issue. error message "could not sign in could not communicate with server when attempting to log in with apple id and password. Any ideas?

    To finish the upgrade setup, can't get past the screen where you need to log in with your apple id and password.  Error message appears "could not sign in" "Could not communicate with the server."  Tried a reboot, but that didn't work or get us anywhere either.

    Go to Settings then down to Facebook then select account then delete account and select remove info and re enter your user name and password and then it will work again

  • Client Not connected with Server

    Hi Experts
    I upgraded my Patch level from 9.0 PL8 to PL9.  Server and Clients are installed and it is working fine but one PC not connected with Server.  While I Connect SAP in landscape server selection Page Port Number shown as 40000 instead of 30000.   I changed Port No from 40000 to 30000 the error Message came as  [message 60070-99999987}.  I attached the Screen shot in this discussion.
    Please help me to resolve this issue.
    With Regards
    Balaji Sampath

    I have same problem and this is the solution
    Go to the directory C:\Program Files (x86)\SAP\SAP Business One\Conf
    Copy the file b1-current-user.xml and put it aside
    Go to the directory %USERPROFILE%\Local Settings\Application Data\SAP\SAP Business One
    Check the file b1-current-user.xml which is likely empty or wrong strings
    Rename the b1-current-user.xml file for backup
    Move the copied file into the directory.
    License server name asked every time on login

  • Could not communicate with server

    In iOS 7 update, I stucked in setting up iCloud.  It kept on saying Could Not Sign In ... Could not communicate with the server.  Would any one know where the problem was and how to fix?  This happened to my previous updates as well.  Thus, my iCloud does not work so far.

    same like me need help

  • SOAP Monitor unable to communicate with server

    We're getting started with a few RisPort SOAP Service requests and we're trying to leverage the built-in SOAPMonitor at (:8443/realtimeservice/SOAPMonitor).
    We can't seem to get the monitor to connect - the exact error is "The SOAP Monitor is unable to communicate with the server."  Any pointers to help troubleshoot this issue?  We're struggling to find any CUCM related info on this one.
    Thanks!

    Have you tried to restart the soap service in CUCM? We had this error with Prime Collaboration once and that was able to resolve it. Good luck. 
    -Ryan

  • Clients losing contact with server

    General network:
    We have a 10.6.2 server which provides DNS, AFP, IChat, Open Directory and Print to our internal network 10.6.2 clients which are bound to the OD by the server's IP address. FQDN of the server resolves both forwards and reverse on the server and the clients.
    Clients were migrated recently to 10.6.2 by upgrading them in place from 10.5.8. The server was upgraded in place. The OD was then Archived and Restored to a fresh install of 10.6.2.
    None of the following happened when the clients and server were 10.5.x.
    Strange problem:
    Since moving to 10.6.2, users which are logged in for a long time (3 hours or more) have most of the services periodically fail due to an apparent inability to resolve the FQDN of the server.
    When this happens, I have been able to get Network Utility on the confused client to resolve the server both ways. But then immediately thereafter the client will tell me that it cannot find the location of "FQDN of server" when trying to connect via AFP. Printer service disappears with the same type of problem. Our clients get printers by browsepolling the server by its IP address in CUPS. The print jobs fail when requesting for example : officeprinter@FQDNofServer. User Sync fails due to inability to resolve the server.
    All of this usually goes away by logging out the user and logging back in again. Sometimes Shutting down and rebooting is required.
    I'm assuming that the problem is in DNS but cannot find anything about the inability of the services to resolve either on the client or the server. I may be looking in the wrong place.
    Thanks - Erich

    I was also just having this same problem; even though my local DNS was listed first, the ISP DNS servers were being queried. This was never a problem when I was running Microsoft's DNS server.
    I was always under the impression that the first DNS server in any computer's list was queried first, and then the other ones if there was no record. Why is that not the case after switching to Apple's DNS server? All the computers now seem to be querying whatever the heck DNS server they feel like, instead of going in order they are listed... Is this a known bug that I'm not aware of?
    I fixed it by following the advice in this forum, but at the cost of a crucial piece of functionality: If I ever restart the local DNS server for any reason, or if it goes down, my whole organization will not be able able to browse the internet. Having the ISP DNS numbers in there let me allow for that possibility, but not anymore.

  • How do I enable two wireless clients to communicate with each other?

    I have a WRT54GL with the latest firmware.  I have two computers which are both connected to the router, with IP addresses assigned via DHCP.  Neither has a firewall running.  I cannot get them to communicate with each other -- even ping doesn't work.  I can ping the router itself using the IP address assigned to it on the WAN side by my ISP.   Both computers have no problem reaching the internet through the router.
    What settings on the router will enable the communication to occur?  I can't find anything in the router's user interface which appears to control this. 
    Thanks.
    Solved!
    Go to Solution.

    Hi annie25,
    I think it would be best to check on netgear or belkin technical forums how to make these two talk. 
    Yesterday is history. Tomorrow is mystery. Today is a gift.

Maybe you are looking for

  • Firefox will not automatically load Tiscali and after I have loaded using START it will not access my e-mails on tiscali

    Until I loaded the latest version of Firefox I accessed Tiscali without difficulty usong the Icon. Now it will not access the internet at all and I have to use Windows to access the internet. Tiscali then loads but i cannot access my e-mails and I ge

  • X305-q725 freezing up, but not in safe mode

    Yo hi you guys doing!  I have showed up on this website a couple times now regarding my qosmio x305 Q725 for support, And I always appreciate the help from some people in this forum . So here I am AGAIN XD !! Today (Actually yesterday) the problem I

  • Attributes passed in HTTP Header but not received in my application!! Help

    Hi all, I am running Sun Directory Server 5.2, Access Manager 7.0 and Policy Agent 2.1 on an IBM Websphere 5.0 web server. I am using a "shared" authorization model where I am using the AM only for the authentication part. The way my application is s

  • Strange text when replying

    Hi, I have a 3G S Iphone I just got last week. While using it this week it came to my attention that sometimes when I replied to an email that had a lot of activity (reply after reply, etc) strange text would appear on top of what I wrote. An example

  • NOKIA Series 60 Error HTTP Connection

    Hi.. Im developing a MIDlet that uses a HTTPconnection The MIDlet worked fine using the Default emulator (Grayphone and the ColorPhone). But when i tried it on NOKIA emulator (Series_60 MIDP_SDK for Symbian OS v 1_0) it couldnt create a connection. I