EXPERT socket programmers help needed please!

I basically have this very simple client/server app, where I can enter messages at the client to send to the server, and the server will display it on its screen.
But how would I extend it to support multi client? So when I send messages from different clients, the server will diplay the message on its screen and also send the message back to all connected clients? Here's my current code
Server:
import java.net.*;
import java.io.*;
public class Server {
    public static void main(String[] args) throws IOException {
     ServerSocket serverSocket = new ServerSocket(5432);
     for (;;) {
         Socket clientSocket = null;
         try {
          clientSocket = serverSocket.accept();
         } catch (IOException e) {
          System.err.println("Accept failed.");
          System.exit(1);
         BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
         String nextline;
         while ((nextline = in.readLine())!=null) {
          System.out.println(nextline);
         in.close();
         clientSocket.close();
}Client
import java.io.*;
import java.net.*;
public class Client {
    public static void main(String[] args) throws IOException {
     Socket csocket = null;
     PrintWriter out = null;
     try {
         csocket = new Socket("localhost", 5432);
         out = new PrintWriter(csocket.getOutputStream(), true);
     } catch (IOException e) { }
     BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
     String nextline;
     while ((nextline = stdIn.readLine()) != null) {
         out.println(nextline);
     out.close();
     csocket.close();
     stdIn.close();
}

jverd wrote:
javaguy86 wrote:
But how would I extend it to support multi client?Ever hear of collections? Loops?Hardly the answer of an expert in Socket programming!!!!

Similar Messages

  • Help needed please.. how do I remove my credit card from itunes? just discovered over $450 of charges when I looked at my email... Kids had no clue they were using our money and not their gift cards

    Help needed please.... I just discovered over $450 charges to my credit card from Itunes. The kids had no idea they were using our credit card and not their itunes gift cards and 4 year old just clicks on anything! I didnt save my credit card details so am a bit miffed at this... I cant find anywhere in itunes to remove it. Edit.. but not remove. Editing does not remove it.. HELP

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    Accepted forms of payment  >  http://support.apple.com/kb/HT5552
    Changing Account Information  >  http://support.apple.com/kb/HT1918

  • Help needed please, with Iphone stuck with apple picture and progress bar after software update attempted

    Help needed please, everytime I try to update the software version on my iphone it comes up with a message saying it could not be completed and is now frozen with the apple picture and progress bar on it. Do I unplug it and hope the macbook pro sees it again, I also stupidly did not back up before starting the download which I realise I will have to go back to the previous back up. This keeps happening, everytime I do this type of update, I'm starting to think I should just give up on updating my software on the Iphone. I thought it was happening because I was using a window based computer to do the updates, this time I used my Macbook Pro. Please somebody help

    ljm17 wrote:
    ...This keeps happening, everytime I do this type of update, I...
    Then you should know what you need to do... If you don't remember...
    See Here  >  http://support.apple.com/kb/HT1808

  • I recently had to restore my Iphone 4s and ever since I cannot double click the home button whilst the phone is locked and change my music. The controls come up and I can adjust the volume but I cannot change the songs. Help needed please!!

    I recently had to restore my Iphone 4s and ever since I cannot double click the home button whilst the phone is locked and change my music. The controls come up and I can adjust the volume but I cannot change the songs. Help needed please!!

    Have you guys been able to activate your iphone yet? I bought an iphone 4s from eBay and it worked fine, but the previous user had left some data on it, so last night I used the "erased all content and settings" to restore it to factory setting so I can start fresh and restore my backup. But now I'm stuck at the activation screen (I get the same "the activation server is temporarily unavailable")  and can't get it to activate, even if I use my old deactivated AT&T sim card (I'm on straighttalk now).
    I might try activating it with an active AT&T sim card from my fiancee's phone when she gets home, so I'll let you know how that works outs.
    If it's true that the server is down; anyone know when it will be back up again? Thanks in advance.
    iPhone 4s iOS 5.1.1 (9B206)
    Carrier AT&T 12.0
    Modem Firmware 2.0.12

  • New Hard drive, can't access certain aspects. Help needed please

    Hi everyone.
    I have an HP Pavilion dv6-6052ea laptop.
    I've been having problems with the hard drive so got a new one installed.
    My main issues are since getting it back, I can't access any of the original HP installations etc (I've downloaded all the drivers I know about through HP).
    The 2 main things I'm missing are 2 things that came with the laptop.
    1: Beats Audio sound system 
    2: Video Graphics: AMD Radeon HD 6490M (1 GB DDR5)
    and I have no idea how to get them back. Can anyone help. Do I need to install specific drivers? I can't find any trace that they exist on my laptop now apart from the stickers on the laptop! Any help is greatly appreciated. 
    I never had any CD back ups for the laptop. I do have the old HP back up etc saved on a USB but I don't know enough about the folders and files to know what I need to look for. (I still have the old hardrive.)
    Again, any help is massively appreciated. Thank you!
    Tony 

    If you used your HP Recovery Media, all factory install drivers and software would have been installed. If you didn't create your HP Recovery Media when you first setup your computer, please contact official HP support in your region / country, via the HP Worldwide Support Portal, to see if HP Recovery Media is available for your computer.
    If a generic Windows 7 installation disc was used, you will need to install all HP specific driver for your computer. Please try IDT High-Definition (HD) Audio Driver, Intel High-Definition (HD) Graphics Driver, and AMD High-Definition Graphics Driver to resolve your missing drivers issues. Windows 7 64-bit driver for your computer can be found on the HP Pavilion dv6-6052ea Entertainment Notebook PC Drivers page.
    If you have any further questions, please don't hesitate to ask.
    Please click the White KUDOS "Thumbs Up" to show your appreciation
    Frank
    {------------ Please click the "White Kudos" Thumbs Up to say THANKS for helping.
    Please click the "Accept As Solution" on my post, if my assistance has solved your issue. ------------V
    This is a user supported forum. I am a volunteer and I don't work for HP.
    HP 15t-j100 (on loan from HP)
    HP 13 Split x2 (on loan from HP)
    HP Slate8 Pro (on loan from HP)
    HP a1632x - Windows 7, 4GB RAM, AMD Radeon HD 6450
    HP p6130y - Windows 7, 8GB RAM, AMD Radeon HD 6450
    HP p6320y - Windows 7, 8GB RAM, NVIDIA GT 240
    HP p7-1026 - Windows 7, 6GB RAM, AMD Radeon HD 6450
    HP p6787c - Windows 7, 8GB RAM, NVIDIA GT 240

  • HELP NEEDED PLEASE

    Hi everyone
    Programming help needed here. Any advice would be greatly appreciated!!!
    I have been assigned some work for a program called Processing 1.0 availale at http://processing.org/download
    I was give the 9 individual programs I needed to make however they were converted to Java files from .pde files. The program is based on Java but only runs .pde files and NOTHING else!
    I decompiled the files and got the source code, but it is a slight variation of the original someone made in processing, and needs some tidying to get it to run.
    I think the programs are very simple for a programmer, although I AM NOT.
    CODE is BELOW
    // Decompiled by DJ v3.10.10.93 Copyright 2007 Atanas Neshkov Date: 02/05/2009 13:15:00
    // Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
    // Decompiler options: packimports(3)
    // Source File Name: Assign2_1.java
    import processing.core.PApplet;
    public class Assign2_1 extends PApplet
    public Assign2_1()
    SquareSide = 20;
    Rank = Nums.length;
    Side = SquareSide * Rank;
    Green = color(0, 255, 0);
    Yellow = color(255, 255, 0);
    BG = Yellow;
    public void setup()
    size(Side, Side);
    background(BG);
    fill(Green);
    for(int i = 0; i < Rank; i++)
    rect(i * SquareSide, 0.0F, SquareSide, SquareSide * Nums);
    public static void main(String args[])
    PApplet.main(new String[] {
    "--bgcolor=#ece9d8", "Assign2_1"
    int Nums[] = {
    6, 14, 8, 9, 2, 3, 4, 2, 8, 3,
    9, 2, 0, 5
    int SquareSide;
    int Rank;
    int Side;
    int Green;
    int Yellow;
    int BG;
    Edited by: chevy1 on May 2, 2009 7:32 AM

    HELP NEEDED PLEASEShouting is a good way ensure you don't get help. Also you should give a meaningful subject.
    Any advice would be greatly appreciated!!!I suggest you ask a question after providing enough information to be able to answer it.
    Also use CODE tags when posting code as it make the code more readable.
    We are more likely to help people who are trying to learn Java rather than someone who might be looking for an easy way out of doing an assignment.

  • ITunes corrupt file message - urgent help needed please

    I have an iPod video 30GB, i downloded the latest iTunes & Quicktime version, and updated my iPod also to the latest update. When i connect my iPod and start downloading music from the library in iTunes, the iPod keeps on disconnecting and restarting by itself, and i get a message that the file iTunes.exe is corrupt. I tried Apple support and did all what they said by downloading the latest updates and versions, and also did the Chkdsk utility on Windows, but still it did not work, the iPod keep on restarting and i cannot download anything on it, i had it now for a week and did not use it at all because of this problem, can somebody with a technical background help me please, i use Windows XP.

    I have an iPod video 30GB, i downloded the latest iTunes & Quicktime version, and updated my iPod also to the latest update. When i connect my iPod and start downloading music from the library in iTunes, the iPod keeps on disconnecting and restarting by itself, and i get a message that the file iTunes.exe is corrupt. I tried Apple support and did all what they said by downloading the latest updates and versions, and also did the Chkdsk utility on Windows, but still it did not work, the iPod keep on restarting and i cannot download anything on it, i had it now for a week and did not use it at all because of this problem, can somebody with a technical background help me please, i use Windows XP.

  • MP3 burning help needed please

    Hi,
    I'm hoping someone can help me please.
    I'm wanting to burn a mp3 cd but with the songs in separate folders so that when i play them in my car i can flick between the albums instead of having to go through all the singles one after another.
    Does anyone know of a good mp3 burner that can do this, and where to get it from too.
    All and any help in this matter is greatly appreciated
    Cheers
    Paul

    You want them in separate Album folders?
    Put the songs into the playlist.
    Sort the playlist by Album then burn it as MP3* disc.
    This will put the songs into Album folders.
    Likewise, if you sort by Artist, songs will be put into Artist/Album/ folders.
    * Note that only MP3 files will be burned to the disc. If the files are not already MP3 format, they will be skipped.
    If you burn it as a DataCD, it wil work the same except it will copy the files regardless of format. I do this as my CD player will work with both AAC & MP3 formats.

  • WLC Logs!!! Quick Help needed please!

    Hello,
       My client want to check who owned a certain IP address on the WLC and from which AP he was associated. I looked at the system logs in the GUI but couldn't get beyond 6 hours. Is there a place I can download last day logs from CLI/GUI? Or Can I login via SSH and extract the logs via CLI?
    Please this is vital and I appreciate your help,
    Regards,

    Please note that the customer is using Pass-Through Web Authentication for the Guest WLAN.
    Thanks,

  • Help needed please for master socket wiring

    I am renovating a house built in the 1970's which I shall be moving into shortly.
    My electrician has put in telephone sockets in two of the bedrooms but when he came to the master socket he found the builders had by mistake cut the wire too short so he could not make a connection.
    The master socket is in the hall low down on the wall and it looks as if the wire comes into the house underground.
    I have spent hours on the telephone trying to get the right person to speak to at BT who tells me I need to contact Open Reach as it is damage and when I eventually found a number to ring them they tell me it is BT's problem.
    In exasperation I telephoned the moving house line as none of the press button numbers seemed relevant.
    I just want a BT person to come and have a look to see what to do but they have told me that I need to give them a date for when I move and they will come and look then.  However, I need the builders to fill in the large hole in where the wire comes into the house so I can have a floor laid.
    Any help would be so much appreciated

    Hi Kh,
    Thank you for your post and welcome to the forum. If you would like a BT Engineer to go out and take a look at your line this can bee arranged when you place an order to activate the service. With the line being damaged by the builder, there will be a charge of around £127.99 to activate the service.
    If you need any help placing your order to activate the service, please drop me an email with any BT account details, along with the address details for you new property. My email address is [email protected]
    Thanks
    Paddy
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Upgrading Mail from 10.3.9 to 10.4.8 Server - Help Needed, Please

    Hi
    I posted a message a few weeks back with regard to this topic, but have had no replies. I don't seem to be any further on in solving this on my own, so I'm posting again in the hope that someone will be able to assist.
    I have an Xserve G4 running 10.3.9 which is a Open Directory Master, PDC and also acts as a Mail Server for our domain. The system software is installed on one 60gb drive in the Xserve and the Mail Store is on a second drive. All the Windows clients can log into the domain and their mail is on IMAP using Outlook as their client.
    I am now installing a second server in another office, and obviously this will be a new XServe running 10.4. I would like to make this an Open Directory Replica but now need to upgrade the first server to 10.4 before I can do this.
    Each attempt has been at the start of a weekend when staff have gone home, so that I can shutdown Mail and clone the Mail Store before proceeding.
    My first attempt was to install a new 10.4 installation onto a drive module and then attempt to upgrade the Mail. I removed the original 10.3.9 startup drive and I cloned the mail store drive before attempting and then followed the instructions given in this article:-
    http://docs.info.apple.com/article.html?artnum=301656
    When running the first part of this script, I get a socket error and don't seem to be able to get beyond this point.
    Next, I atttempted a straightforward upgrade. To do this, I again cloned the Mail Store onto another Drive Module, and so that I could roll back in case of problems, I also cloned the startup drive. Once this was done, I then removed the original drives for safety, booted and proceeded to upgrade the Server software from 10.3.9 to 10.4 performing all updates along the way.
    When I first booted, I had quite a lot of errors, DNS zones hadn't come over, and I had to kerberize the system, but after doing this and several restarts to cure other problems, all seemed to be OK, but then when I invoked Windows services and tried to log into the domain from a PC client, it failed saying the Domain Controller wasn't available, and the server log shows "Broken Pipe" errors and I cannot seem to resolve these issues. Server admin, also now loses connection with various services at intermittant times and I have to reboot.
    So, my conclusion is that the 10.3.9 installation on this server is way too flaky to be upgraded and I must find another way.
    Ideally, what I would like to do, is install a brand new 10.4 system onto the server, setting up DNS, Open Directory etc etc ensuring that my clients can log into the domain (copying their profile to the new account if necessary) and then upgrade the Mail once it is all stable. Can anyone help me with this by giving me a step by step guide? I am willing to pay for someone who knows how to do this if they can help me with a guide or perhaps even provide remote assistance.
    Thanks in advance
    Paul
    PowerBook G4 17"   Mac OS X (10.4.8)   G4 Xserve 1GHz, 1.5GB RAM, 10.3.9 Server

    They've never heard of a G4? That's shocking, perhaps you shouldn't go there anymore :P.
    OS X 10.5 requires at least an 867 MHz G4, unfortunately. You can upgrade to OS X Tiger (10.4) though (Just run software update after installation to get to 10.4.11).
    You can find Tiger cheap on eBay or the likes, note you must buy the full retail version which looks like this:
    http://jimbox.homedns.org/rants/images/uploads/tiger1.jpg

  • Restore help needed please.

    I need help. I got a new iPhone today and I went to iTunes, pressed restore, because I didn't know what else to do.
    And now because it was logged in under my boyfriends apple ID my iPhone is my boyfriends iPhone too.
    How do I turn it back to mine!? I need urgent help please!

    Go to Settings > General > Reset > Erase All Contents and Settings. Now this time, select Set Up as New iPhone rather than Restore from Backup.

  • Error in database reading ! help needed please.

    My project involves monitoring of ovens.
    The temperature from the oven are obtained using advantech ADAM module.
    Each material enters the oven and an alert is given to take it out after the desired time inside the oven.
    When i execute this program. an error pops up exactly 1 our after the start of the program.
    Kindly help me.
    I have attached the source code including the DB files and the error screen shot.
    username: 123456
    pass: 123456
    Thank you ina advance.
    Please help figure out the error.
    Regards
    Grugh Mike
    Success is Everything !!
    Solved!
    Go to Solution.
    Attachments:
    New Microsoft Word Document (2).doc ‏151 KB
    source.zip ‏4529 KB

    The biggest problem in your code is architectural. You need to learn about a few things like event-driven programming. As but one example you have an administrative operations VI that would be much smaller and much more efficient if it were built around an event structure and not multiple case statements. Your main application uses sequence structures - which are never necessary. As I recall, the last sequence structure I used in deliverable code was in the spring of '88.
    You also are not handling any of errors - which I suspect might be the source of your problem. It's possible that due to an error (which is going unreported) that a connection is being left open when you think it is being closed. But at this point that is just a guess.
    Fix the structural problems and you'll then be able to troubleshoot your DB problem. Shoot, in the process of fixing the structural issues, you may fix the DB!
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • IReader installed but wont open Urgent help needed please!

    I have installed Acrobat Reader X.
    When i try to open files I get a problem saying Microsoft and Adobe have encountered a problem and need to close.
    I get an option to Debug, Send error report or Dont send.
    The information which comes up when I look for more information is the following::
    error signature
    Appname. Acrord32.exe. Appver 10.0.1.434 Modname acrord32.dll
    Modver 10.0.1.434  offset 001869666
    It was previously working then the next time I came to use it I got this.
    Desparately need help

    1. camera loading - have you tried updating or reinstalling your firmware?
    2. keyboard - define strange
    3. slow - how much is phone memory and what apps are running in background (see taskmanager, hold menu key until it shows)? turn off theme animations. it helps.
    4.  handwriting - have you set the handwriting recognition to recognize your particular penmanship? Go to menu>settings>phone>touch input. Set writing speed to very fast, calibrate your screen and take handwriting training so the phone will recognize your handwriting.
    5. qwerty - what things? how so? have you set it to qwerty?
    6. cannot scroll in file manager - its not a problem. Thats normal for the OS. Use Nokia Photobrowser or the Gallery for viewing pictures. File manager is for managing files, not viewing them.
    7.  Motion sensors - read #3
    8. Phone feels hot - how hot? Batteries heat up when charged. Its normal. However it depends on how hot exactly.
    9. Depends maybe on how long the video is. My 5800 feels hot when watching an entire movie. Also this would be reflected on #3 as well, as the phone may be working overtime.
    10.  Music when unplug headset - Its normal for almost all Nokia phones (heck even some other brands this is normal), try to use an alternative player if you like
    11. Back cover -  Its the design
    12. Yotube - use youtube app
    13. Use Nokia Photo Browser download from ovi store. It shows pics only and looks real cool. Anyway, you can put all your videos in the gallery into a virtual folder so that it is separate. Its the way the gallery is designed, to show both pics and video. As you can see, it is written Images and Videos, so they're supposed to be together in there.
    14. Adobe still hasnt caughtup its mobile solutions for its PC solutions. Its their fault not Nokia's or anyone else's.
    15. Depends on extension. Built in office reader only reads .doc, not .docx.
    If you find my post helpful please click the green star on the left under the avatar. Thanks.

  • ? symbol in Keynote - Help Needed please !!!!

    Hi,
    New to Mac and even newer to keynote.....
    when i open a new slide there are ? symbols on the slide which appear also when i play the slides....
    is this an error or not ?
    If its an error what does it mean and if not how do i remove them ?????
    Please help as my daughters homework needs doing (by her obviously, not me)
    Thanks
    Nick

    Here are a few things you can do to troubleshoot the problem:
    - Have you tried re-recording the entire song playlist? This would be the first thing to try.
    - If it still skips, does it play OK in the Editing mode (not in Presentation mode)? If so, there may be a problem with the way you Recorded the Soundtrack.
    - Try recording just "Beautiful Day" as a Soundtrack and see if it still skips. If so, then this track itself may have some "glitches" and need to be replaced with a new copy.
    - What is the processor speed of your playback computer? With some presentations the audio will skip on slower machines, but not faster ones. (e.g. Some audio tracks will skip on my G5 desktop but not on my MacBook Pro.)
    Good luck

Maybe you are looking for

  • Adobe Acrobat 8 Professional - will not uninstall

    I tried to install this program with Windows 7, 64-bit numerous times and it would not work 100%.  I even downloaded the "patch" file for windows 7, but the program would freeze every single time I opened it.  I have since reverted back to just using

  • 2.2 Generation one Ipod touch having trouble connecting to wifi

    Ok, I am having a BIG issue with connecting my ipod touch to a linksys WRT54GX4 wireless router running WPA/WPA2 wireless security (there is an option that allows BOTH to be selected, but I disabled WPA2 as an option after I first started having issu

  • CSS on a template shows a different style on the actual web page.

    I have created a template and made my sub pages according to the template. Late I have made some changes to the template and all the changes (Basic HTML changes) got effected on the pages that referring the this template. The I attached a style sheet

  • Word 2013 Simplify Places in File Open Menu

    Hello all, Working to help my aged parents (87 and 84 years old) working with Office 2013.They have an Office365 account (so they have a website and a Skydrive PRO place for their files) They have new computers with Windows 8 / Office 2013. Since the

  • Exclusive access could not be obtained because the database is in use

    Hi I am trying to use sql server 2005 management stodio to restore a database. But I got this error message: Exclusive access could not be obtained because the database is in use Anyone know how to solve this problem? Thanks Li