NIO Echo Server SocketChannel.write() multiple times?

Hello,
I have found and experimented with two simple nio echo socket servers,
one from hutchinson's book. The other has similar code:
     if (key.isWritable())
     SocketChannel client = (SocketChannel) key.channel();
     ByteBuffer output = (ByteBuffer) key.attachment();
     output.flip();
     client.write(output);
                     output.compact();
     }but in my client, I noticed that when I send something to the server,
apart from echoing it back it also sends back about 90 empty
strings, which fire in my client's onData() event.
Is this normal or am I missing something?
Message was edited by:
Robse

This code is correct, and it can't send empty strings. The error is elsewhere.

Similar Messages

  • Using tiles - servlet filter called multiple times

    Hi I have an application in we have 7 filters defined.
    Now in a jsp page, I have a loop that inserts a TILE. The loop iterates about 7000 times. Every time the tile insert is called, even my filters are called. So my 7 filters are called 7000 times. Now this makes my page rendering really slow.
    setting flush="false" (in the tile insert) does not work
    setting buffer="2700k" autoFlush="false" does not work.
    I have to use tiles. I cant skip the filters. What do I do? Is there any way I can not call the filter when my tiles are inserted.

    Hi
    Yes,you are right. In iAS6.0 SP4 When multiple requests arrive,and the Servlet's init() method has not returned yet for the first request, the application server calls init()multiple times. This problem is resolved in iAS 6.5.
    There is no kregedit magic that will solve this problem.
    Right now the workaround is any of the solution you proposed. Or use iAS6.5. I have tested it with fortune.
    Please download it and check with your application.
    you can find free download at http://developer.iplanet.com/appserver/testdrive/testdrive_65.html
    Thanks

  • Servlet init() method called multiple times

    We have a Servlet-based application which does lengthy initialization.
    We've noticed that when multiple requests arrive,
    but the Servlet's init() method has not returned yet
    for the first request, the application server calls init() multiple times.
    You can even see this with the Fortune sample
    Servlet. Starting the app server and sending 20 or 30
    simultaneous requests causes multiple Fortune Servlet init messages to appear in the kjs log.
    Why is this? We do not implement SingleThreadModel.
    Doesn't the J2EE 1.2 spec say init will be called
    only once?
    How do we prevent it?
    A Startup class which inits our
    Servlet?
    Or a synchronized block within our init method, with some checks of static member variables
    so that the initialization work only happens once?
    Or is there some kregedit magic or deployment descriptor change I could make?
    Again, it's not a SingleThreadModel issue, so don't
    point me there.
    This is iAS 6.0 SP4, on Solaris, by the way.

    Hi
    Yes,you are right. In iAS6.0 SP4 When multiple requests arrive,and the Servlet's init() method has not returned yet for the first request, the application server calls init()multiple times. This problem is resolved in iAS 6.5.
    There is no kregedit magic that will solve this problem.
    Right now the workaround is any of the solution you proposed. Or use iAS6.5. I have tested it with fortune.
    Please download it and check with your application.
    you can find free download at http://developer.iplanet.com/appserver/testdrive/testdrive_65.html
    Thanks

  • Can I do multiple installs on  one server at the same time ?

    Hi. we have a project where the basis group is under very tight deadlines. We are tasked with installing multiple SAP systems on the same server. Is it possible to install more than one SAP systems ( ie ERP, BI, EP, CRM ) on the same physical server at the same time. for example on analyst install ERP while at the same time another analyst do EP and so on....  Has anyone done that before and if so are there any issures. ( I put in a SAP note and got the response that this is not supported, but I just wanted to see if anyone had done it anyways )

    Hi Dan,
    Frankly simultaneous installations is not a great idea. There will be an enormous competition for resources. Then you also need to make available ports for carrying out the installations. Next it will involve high amount of coordination
    What of course is more reasonable is the idea of hosting more than one SAP instance on the same physical server though again harware is a very important concern. It includes your hard disk space,memory,CPU and other generic hardware.
    Please award points for useful answers.
    Regards.
    Ruchit.
    Message was edited by:
            Ruchit Khushu

  • When I enter my password to start my atv it tells me, that "there was a problem connecting to the network."  My Ipad works fine but not my new atv.  I have reset my password multiple times with no help.  I have also rebooted my wireless server.take it bac

    When I enter my password to start my atv it tells me, that "there was a problem connecting to the network."  My Ipad works fine in my house, but not my new atv.  I have reset my password multiple times with no help.  I have also rebooted my wireless server.  Do I take it back?

    Where is everyone????  Does anyone have an answer???
    Allik1

  • TS4268 I am trying to facetime on my mac but keep getting the message "The server encountered an error processing registration. Please try again later." I have gotten this multiple times. how can I get around this?

    priority:
    I am trying to facetime on my mac but keep getting the message "The server encountered an error processing registration. Please try again later." I have gotten this multiple times. how can I get around this?
    i also have tried downloading "FaceTap" application to get facetime on my ipad and failed too. i thought i failed because i couldnt download latest 6.0 iOS or later. i downloaded latest software update for iOS but was 5.8 I think

    Wait until Apple fix it. See: http://www.apple.com/support/icloud/systemstatus/

  • I keep getting a server error and my emails are not deleting and showing up multiple times

    I am getting emails multiple times and they aren't deleting.  They keep coming back.  I then get a server errer that mail.me may be a false server pretending to be mail.me.  Don't know how to fix this.

    Update and restore alert messages on iPhone, iPad, and iPod touch
    http://www.buybuyla.com/tech/view/012953a0d412000e.shtml
    iOS: Resolving update and restore alert messages
    http://support.apple.com/kb/TS1275
    iPad: Unable to update or restore
    http://support.apple.com/kb/ht4097
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    http://support.apple.com/kb/TS3694
     Cheers, Tom

  • Write to File Multiple times WTK 2.5.2

    Hello All
    I am trying to write to a file multiple times (in WTK 2.5.2 on Win XP SP2). So I create a FileConnection and create a PrintStream with it. Using the PrintStream I write data to the file multiple times.
    The problem I am facing is that the write happens the first time (after the usual security prompts) and not after that. The code is below. The second time onwards the security prompt displayed does not get closed and the application remains non responsive
    public class IOWriter {
         private PrintStream out;
         public IOWriter() {
              String sMemCardRoot = System.getProperty("fileconn.dir.memorycard");
              String sFileName = "System.out.txt";
              try {
                   FileConnection fc = (FileConnection)Connector.open(sMemCardRoot + sFileName, Connector.READ_WRITE);
                   if(!fc.exists()) {
                        fc.create();
                   out = new PrintStream(fc.openOutputStream());
                   println("Initialized");
              } catch (Exception e) {
                   e.printStackTrace();
         public void println(String sData) {
              if(null != out) {
                   if(null == sData) {
                        sData = "";
                   out.println(sData);
                   out.flush();
         public void unInit() {
              out.close();
    }I have set the fileconn.dir.memorycard System property to a folder
    I have been trying to debug this in the WTK for some time now. have not tested on a device yet. Let me know if you could identify the problem.
    Thanks & Regards
    Edited by: SonieThomas on Jan 19, 2009 1:51 AM
    Edited by: SonieThomas on Jan 19, 2009 1:54 AM

    It sounds like you need to Use the open\create\replace VI to open a data file and get a reference to it. You use the Write File node to write the data, specifing the start pos as 0, and the offset as the current file marker. When you're done with the data file, you use the Close File node to release the file reference.
    I've written a Sub VI that should do what you want, or come close. Take it apart and see how it works. I'm including a VI that uses the Sub VI to create and append text data.
    I hope this helps!
    John Wilson
    Sanders Engineering & Analytical Services, Inc.
    Mobile, AL
    251-633-4120
    [email protected]
    Attachments:
    test_writing_gpib_data_file.vi ‏26 KB
    write_gpib_data_string.vi ‏84 KB

  • JOB in Sql Server Agent should run multiple times.

    Hi Guys,
    I have a ETL SSIS job in Sql Server Agent, Which should run multiple times.
     1. For Example : I scheduled a job at 10:00 PM, If the job fails at 10:00 PM it should run automatically again at 10:10 PM, if the job fails again at 10:10 PM then the job should run at 10:40 PM.
    If the job gets success at first attempt i.e 10:00 PM, then it should not run at 10:10 PM.
    Note : The time difference between jobs is 10 minutes and 30 minutes. And i know that we can run the job at regular intervals.
    Thanks in advance

    Just add retry attempts to whatever number you want (2 as per your original explanation) in Job step properties as below
    Have a logic to include a delay of 10 mins . You can make use of WAITFOR function for that
    see
    http://www.mssqltips.com/sqlservertip/1423/create-delays-in-sql-server-processes-to-mimic-user-input/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • SWF requested multiple times from server

    Hi,
    We have implemented an SWF in our homepage, using normal object tags. The SWF source is called from our database.
    Loading works fine, and the SWF plays OK on the page. However, using firebug or httpwatch, we can see that the same SWF is requested multiple times from the server. We only have 1 instance of the SWF on our page. At the moment I can see 6 requests to the full SWF file (about 360kb) and another 8 requests to the same file, but with a lower filesize (about 98kb).
    How is this possible? We tried using different browsers but they are giving the same results. Google doesn't answer my question, so maybe one of you can help me out here?
    Thanks in advance!

    what's your url?

  • How to write a Timer application and deploy on an application server?

    Hello Everyone,
    How to write a Timer application which can be triggered according to a
    specified timetable and deploy on an application server?
    I know JMX(Java Management Extension) support Timer service, but my context
    is the service execute according to a tabletime
    user specified,not periodically. Do u know what i mean?
    Thanks in advance.
    Nov 4,2002

    Woodsonli,
    What about using a third party J2EE scheduler like Kronos
    See the following link
    http://www.indcon.com/
    Would that suit your needs?
    Chuck Nelson
    DRE
    BEA Technical Support

  • Can CPS be installed multiple times on same server

    We have implemented CPS in our environment but want to know
    if CPS and can be installed multiple times the same server. We are
    using Contribute 3 as the client but our users don't know if they
    want to share administration for both Intranet and Public site
    development. So we have to see what are real options are.
    Thanks for any respones in advance.

    When you say share administration are you referring to user
    administration? There's no reason to need more than one instance
    unless you are allowing them to independently manage their
    users.

  • Emails I write on laptop go to BB multiple times

    Every email i write from my laptop (macbook) go to my mail folder multiple times.. I read on this site that i should go to Options/Email Settings/Message Services/ Folder Redirection:  and there I should Un check the SENT folder.. But I do not have one.. How can I stop this from happening?  It is driving me crazy having to delete 20 emails at a time in my BB!

    Every email i write from my laptop (macbook) go to my mail folder multiple times.. I read on this site that i should go to Options/Email Settings/Message Services/ Folder Redirection:  and there I should Un check the SENT folder.. But I do not have one.. How can I stop this from happening?  It is driving me crazy having to delete 20 emails at a time in my BB!

  • Upload client data to task server multiple times in same day

    I am just getting started setting up the task server piece of ARD. My task server is an Xserve(PowerPC 10.4) and my client computers are mostly eMacs running 10.4. My client computers are all running Deep Freeze by Faronics which causes the hard drive to be restored to it's original state after a restart.
    My question is - where does the report information about the client computer get stored before it is uploaded to the task server. Is it cached on the local client machine? My concern is that if the client computers don't upload their data until the end of the day and a student restarts a computer during the day we won't have a whole day of data recorded for that machine.
    If this is the case, is there any way to upload the data to the task server multiple times in the same day?
    Thanks!

    I am collecting User History and Application Usage. Where is the cache stored - on the local client machine or on the task server? If it's stored on the local machine and one of the students restarts the computer the data will be gone because of the Deep Freeze program. That's why I'm trying to figure out a way to upload the data multiple times throughout the day.
    I'm hoping that the data is cached on the task server so that I don't have to try to upload multiple times.

  • Unable to email photos, receive a statement that the server does not recognize my username and or password, have checked multiple times that these are correct

    I am unable to e-mail  photos, receive a statement saying that the werever does not recognize my username and or password. I have checked multiple times and these are correct.

    The box comes up that says "server does not recognize username or password".
    That error message usually will pop up, when there is a conflict between the "From" setting for the mail account you are sending from and the selected outgoing mail server. Probably the outgoing Mail server is receiving a user name and password it does not understand. When the mail returns unsent, do you see the "Try again" panel with the option to select a different outgoing mail server?
    If you do not see this panel, change the Mail "Preferences > General" to "If Outgoing server is unavailable: Show a list of alternate servers". This way, you will know, which server Mail is trying to send from.
    Have you tried to set "From"  pop-up menu to one of your other email addresses?  If that works, change your settings in Mail to always send from this address. You can set this option in the Mail "Preferences > Composing: Send New Messages from". I have my "Send New Messages from" set to "iCloud". That is working best for me with iPhoto.

Maybe you are looking for