Once I send 1 string, the rest are cut off, any ideas?

Hello everyone.
For some reason when I send my first string through the socket, everything works fine. But after that Its cutting off the first 2 or 3 characters of the string and I have no idea why because I'm flushing the output buffer before and after I send the the string to the output buffer.
note: complete code can be found here:
http://cpp.sourceforge.net/?show=38132
Am I not flushing right?
Here's the code:
public class MultiThreadServer implements Runnable {
//csocket is whatever client is connecting to this server, in this case it will
//be a telnet client sending strings to the server.
     Socket csocket;
  MultiThreadServer(Socket csocket) {
    this.csocket = csocket;
  public void run() {
       //setting up sockets
       Socket outputServ = null;
       //create a message database to store events
          MessageDB testDB = new MessageDB();
       try {
      //setting up channel to recieve events from the omnibus server
         BufferedReader in= new BufferedReader(
                    new InputStreamReader(
                    csocket.getInputStream()));
         PrintWriter out2
          = new PrintWriter(
          new OutputStreamWriter(
          csocket.getOutputStream()));
         //This socket will be used to communicate with the z/OS reciever
         //we will need a new socket each time because this is a multi-threaded
         //server thus, the  z/OS reciever (outputServ) will need to be
         //multi threaded to handle all the output.
         outputServ = new Socket("localhost",1234);
         if(outputServ.getLocalSocketAddress() == null)
              System.out.println("OutputServer isn't running...");
         //Setting up channel to send data to outputserv
          PrintWriter out
               = new PrintWriter(
               new OutputStreamWriter(
               outputServ.getOutputStream()));
     String input;
     //accepting events from omnibus server and storing them
     //in a string for later processing.
     while ((input = in.readLine()) != null)  
          //looking to see what telnet gets
          out2.println(input);
          out2.flush();
         //accepting and printing out events from omnibus server
         //also printing out connected client information
          System.out.flush();     
          System.out.println("Event from: " + csocket.getInetAddress().getHostName()
                        +"-> "+ input +"\n");
         System.out.flush();
              //sending events to output server
          out.flush();
              out.println(input);
              out.flush();
              //close the connection if the client drops
              if(in.read() == -1)
                   System.out.println("Connection closed by client.");
                   break;
    //cleaning up
      in.close();
      out.close();
      outputServ.close();
      csocket.close();
       catch (SocketException e )
            System.err.println ("Socket error: " + e);
       catch(UnknownHostException e)
            System.out.println("Unknown host: " + e);
          catch (IOException e)
           System.out.println("IOException: " + e);
}Here's some example output I'm getting from the telnet screen which is (out2) stream:
This is a test
This is another test
his is another test
This is yet another test
his is yet another test
This is a test worked fine, as you can see, it outputed This is a test when I typed it in.
The next string "This is another test" fails, as you can see its echoing out:
his is another test
I'm also printing out the contents to the console, and i'm getting out the same thing:
Enter port to run server on:
3333
Listening on : ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=3333]
Waiting for client connection...
Socket[addr=/127.0.0.1,port=2184,localport=3333] connected.
hostname: localhost
Ip address: 127.0.0.1:3333
Event from: localhost-> This is a test
Event from: localhost-> his is another test
Event from: localhost-> his is yet another test
Connection closed by client.
ANy help would be great!
Message was edited by:
lokie

I posted more compact code so its easier to see and understand: The run() function is where the problem is occurring.
//SAMPLE OUTPUT FROM CONSOLE
Enter port to run server on:
3333
Listening on : ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=3333]
Waiting for client connection...
Socket[addr=/127.0.0.1,port=2750,localport=3333] connected.
hostname: localhost
Ip address: 127.0.0.1:3333
Event from: localhost-> This is a test
Event from: localhost-> his is a test
Event from: localhost-> his is a test
Connection closed by client.
//------END OF SAMPLE OUTPUT-----//
//---THis class is called everytime a new thread is created,
//only 1 thread is created because only 1 client is connecting to the
//server
package server;
//parser server
import java.io.IOException.*;
import java.io.*;
import java.net.*;
import java.util.Scanner;
public class MultiThreadServer implements Runnable {
     Socket csocket;
MultiThreadServer(Socket csocket) {
  this.csocket = csocket;
public void run() {
       try {
    //setting up channel to recieve events from the omnibus server
       BufferedReader in= new BufferedReader(new InputStreamReader(csocket.getInputStream()));
     String input;
     //accepting events from omnibus server and storing them
     //in a string for later processing.
     while ((input = in.readLine()) != null)  
       //accepting and printing out events from omnibus server
       //also printing out connected client information
          System.out.println("Event from: " + csocket.getInetAddress().getHostName()
                      +"-> "+ input +"\n");
          System.out.flush();     
            //close the connection if the client drops
            if(in.read() == -1)
                 System.out.println("Connection closed by client.");
                 break;
  //cleaning up
    in.close();
    csocket.close();
       catch (SocketException e )
            System.err.println ("Socket error: " + e);
       catch(UnknownHostException e)
            System.out.println("Unknown host: " + e);
          catch (IOException e)
           System.out.println("IOException: " + e);
//This is the main function, the only thing it does is
//create a new thread on each connection.
package server;
//This is the parser Client that will parse messages and send to the
//z/Os output Server
import java.io.*;
import java.net.*;
public class MainTest
       public static void main(String args[]) throws Exception
            //get console input
            BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));  
            System.out.println("Enter port to run server on: ");
            String input = stdin.readLine();
            int servPort = Integer.parseInt(input);
            //setting up sockets
            ServerSocket ssock = null;
            Socket sock = null;
            try
            //setting up server to run on servPort
           ssock = new ServerSocket(servPort);
            System.out.println("Listening on : " + ssock);
            System.out.println("Waiting for client connection...");
              while (true) {
                //waiting for client to connect to server socket
                sock = ssock.accept();
                System.out.println(sock + " connected.");
                //get host information
                InetAddress clientIa = sock.getInetAddress( );
                String clientName = clientIa.getHostName();
                String clientIp = clientIa.getHostAddress();
                int localPort = sock.getLocalPort();
                System.out.println("hostname: "+clientName  +
                          '\n' + "Ip address: " + clientIp
                          +":"+ localPort + "\n\n");
                new Thread(new MultiThreadServer(sock)).start();
            catch (SocketException e )
                 System.out.println ("Socket error: " + e);
            catch(UnknownHostException e)
                 System.out.println("Unknown host: " + e);
               catch (IOException e)
                System.out.println("IOException: " + e);
}

Similar Messages

  • Please help i started my project video format 720HD resolution 12x720 rate 25p at last when i finish and burn to dvd the edges are cut off any one help please i am really in trouble

    please help i started my project with  video format 720HD, resolution 12x720, rate 25p.  at last when i finish and burn to dvd the edges are cut off and my logo cut off the screeen aswell any one help please i am really in trouble. thanks

    Sorry, but I don't know anything about that app.
    I did go to their Web site and I see they have a support link. Perhaps you can get help there or in their forum.
    If you are OK with a DVD with a basic menu, you could try the Share>DVD option in FCP.
    Good luck.
    Russ

  • Running windows 7 64bit. since upgrading to newer versions of itunes,display is not right. window controls and side scroll are cut off. any ideas please.

    i'm running Win 7 64 bit. since upgrading to newer versions of itunes,the display is wrong. window controls and side scroll bar are cut off. any help will be appreciated. I've set itunes compatibility setting to Win 7.

    Hi @prdstudio3 ,
    Thank you for visiting the HP Support Forums. The Serial Number needed to be removed from your Post. This is From our Rules of Participation:
    Protect privacy - yours and others'. Don't share anything about yourself that you would not want to see on a road-side billboard. Don't post contact or other personal information-your own or anyone else's-or any content that you receive in one-to-one communications without the author's consent. For example, don’t post your computer’s serial # or contact information publicly, and do not allow someone you don’t know to remotely take control of your computer.
    If you need people to contact you directly, either ask them to send you a private message or subscribe to the thread so you will be notified when there are replies. You may also click on your name anywhere in the forum and you will be taken to your profile page, where you can find a list of threads you have participated in.
    Sharing personal email addresses, telephone numbers, and last names is not allowed for your safety. If you have any questions feel free to send me a private message in reply.
    Thank you
    George
    I work for HP

  • Images at the bottom of the screen are cut off in HDR Pro

    I'm running a Mac and have recently installed CS5.  When I open files to do an HDR, the photos used in the HDR are cut off at the bottom of the screen.  In other words, what I mean is, they should be able to be selected with the check box is being included or not.  Also, the "OK" and "Cancel" buttons are cut off.  I thought that perhaps it was the screen resolution or perhaps the dockeed icons below.  Yet, I'm using the highest screen resolution and that's not a factor. I've hidden the dock,moved it...no difference. I've tried resizing the HDR window but it only resizes horizontally - not vertically.
    This is frustrating.  I'd like to be able to see the entire images being used in the HDR pro and decide whether to include them (or not) by the check boxes; especially since this is how it's supposed to work.  Any ideas?

    Hi Charles,
         Until just now...it didn't work.  Isn't that how it is...ya ask for an answer for something that's broke...then it works.
    When it wasn't working...the Green maximize button didn't do much except allow me to pull the window down further.  Once I would try to resize the window from the resize section at the bottom right, the window would resize to full size...not much good.
    Although...for whatever reason, it seems to be working now.  Will it work tomorrow?  beats me.
    Thanks for yoru help.
    Tony

  • After burned to dvd the edge are cut off in my tv screen. looks like zoomed

    hi
    i am FCPX user. i create my project using format (resolution )as showed on the pic below
    after burned to dvd the edge are cut off on my tv screen. looks like zoomed as showed in  the pic below.
    thanks for taking ur time to help me!!
    then i export using master file as
    showed on pic below
    and after i burn on to dvd my edge are cut off. here pic trying to show before burn on my mac and after burned on to dvd
                                           before burned on to dvd on my iMac screen
                      AFTER BURNED ON TO DVD ON MY TV SCREEN
    i really need ur help thanks
    after burned to dvd the edge are cut off in my tv screen. looks like zoomed

    Thanks Alchroma
    i used this dvd burner just incase..
    but i thought i might have wrong settings from begning.
    do u thinik this setting is alright when creating DVD
    Alchroma wrote:
    That thought jumped into my head as well.
    If the Safe Area settings are OK then it's well a settings issue in either the DVD player or TV or both.
    Al
    Alchroma wrote:
    That thought jumped into my head as well.
    If the Safe Area settings are OK then it's well a settings issue in either the DVD player or TV or both.
    Al
    thanks again

  • I recently purchased 3 CD's, some of the songs are cut off in the middle of the song.  Itunes sent me a link several times to redownload the songs, but each time either the same songs or different songs would be cut short each time I redownloaded the CD's

    I recently purchased 3 CD's, some of the songs are cut off in the middle of the songs.  Several times ITunes sent me a link to redownload the CD's or certain songs and each time either the same songs or different songs on the CD's would be cut short.  What could be causing this?

    shameless bump

  • My songs are cutting short, any idea why?

    my songs are cutting short, any idea why?

    Assuming you are in a region where you are allowed to redownload your past music purchases, delete the broken tracks from your iTunes library, go to the iTunes Store home page, click the Purchased link from the Quick Links section in the right-hand column, then select Music and Not on this computer. You should find download links for your tracks there.
    If you don't see them straight away it may help to close and restart iTunes.
    While downloading select Downloads in the left-hand column and make sure Allow Simultaneous Downloads is unticked.
    If the problem persists, or that facility is not yet available in your region, contact the iTunes Store support staff through the report a problem links in your account history, or via Contact Support.
    See also: HT2519 - Downloading past purchases from the App Store, iBookstore, and iTunes Store
    tt2

  • My iPod says "cannot be synced. The required file cannot be found. Always when half way through a sync. It also shows apple logo when I try to access photos and I think the issues are linked. Any ideas?

    My iPod says "cannot be synced. The required file cannot be found" it also defaults to apple logo when I try to access photos. I think the issues are linked. Any ides?

    So you have tried removing/trashing your iPod's photo cache? See here for more information on where to find this file.
    iTunes: Understanding the iPod Photo Cache folder
    B-rock

  • I imported about 300 RAW images yesterday and worked with them for about an hour. iPhoto locked up on me and I rebooted. After I did the event icon is now gray and it says there are no photos. I know the photos are there. Any idea how I can recover them?

    I imported about 300 RAW images yesterday and worked with them for about an hour. iPhoto locked up on me and I rebooted. After I did the event icon for that event is now gray and it says there are no photos. I know the photos are there. Any idea how I can recover them?

    a best practice to is to never have any computer program (including iPhoto) delete the photos from the card but to import the photos and keep them and then after at least one successful backup cycle has completed and then reformat the card --  I use three very large (32 GB) cards in rotation so I do not reformat for typically a year or more giving me one more long term backup of my photos
    Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your iPhoto library database
    LN

  • I am using Acrobat Reader 11.0.10 . I cant print mixed originals and also I cannot print letter size correctly . printing of first two pages ok but the rest gets cut off at the top

    How can I print from MAC with Acrobat Reader. I can't seem to get it to print correctly , first two pages of letter size works ok after the remaining pages get moved up and the printing is cut off.

    I arrived here looking for a solution!  And while reading your post the penny dropped that I didn't have a serious problem.  I have a booklet of 112 pages and all I needed to do was re-order the pages as printed so that 1 is followed by a sheet with 2 on the under-face but same side and so on.  The pages had printed back to front and needed flipping.  But then I have a duplex printer and maybe that makes a difference.  Is it to do with your manual duplexing and the order that the second pass is presented to the printer.  As my duplex sheets effectively needed flipping over each one I'm wondering if you can solve your problem with a little experimentation and re-ordering before your second pass.

  • My dad has a brand new iMac. If he quits an app, this window closes, but the app won't finish shutting down, Force quitting does not work.  Once another app is opened, it will not close either.  Now none of the apps are responding. Any ideas?

    My dad has a brand new iMac. If he quits an app, this window closes, but the app won't finish shutting down, Force quitting does not work.  Once another app is opened, it will not close either.  Now none of the apps on the dock are responding. I asked him to click on the apple, and drop down to "About this Mac", but that wouldn't open either. Any ideas?  If I was at his house, I would call Apple Care in a heartbeat, but am home with my sick daughter,,,  Thanks!

    For starters, have him open Disk Utility in Applications>Utilities, select the volume (the indented listing) and Verify Disk. If it reports any problems, have him try a Safe Boot by holding the Shift key at startup. This boot will take much longer than usual. It's checking and trying to repair the drive directory, if possible. Once in Safe Boot, have him repair Permissions.
    For other Disk repair remedies see
    http://support.apple.com/kb/TS1417
    Also, have him try a PRAM Reset. At the startup chime, hold down CMD-Option-P-R together, listen for two more chimes, total three, then let go to finish booting.
    Also, is he running any AV? If so, have him uninstall it. It might be responsible for this behavior. (There are no viruses for OS X.)

  • I can only see a small section of the text in the url bar, the rest is cut off.

    Recently my url bar only displays the first handful of letters in my url. If I use the arrow keys I can see all the text is there, and hitting enter brings up the right page, so it's not cutting off the text, just the display. Approximately the first 15% of the url bar shows text, while the leftover bar is just grey. I'm currently on 16.0.2.

    The problem is the same as the one in cor-el's linked question. However, I've found that re-enabling the Authen-tec add-on and restarting firefox solves the problem. It's just when I have it disabled that the address bar does the weird truncation.

  • Font size too large on itunes summary page . Half the words are cut off.

    How to change font size on the itunes summary page? Currently font size is too large resulting in sentences being cut off.

    Did you increase the minimum font size?
    If you increased the minimum font size then try a lower setting (default is ''none'') as a too high value can cause issues like you described.
    Tools > Options > Content : Fonts & Colors: Advanced > Minimum Font Size
    Tools > Options > Content : Fonts & Colors: Advanced > "Allow pages to choose their own fonts, instead of my selections above"

  • I used the ticker tape mode to add subtitles to a clip. When playing it in the pc, the Subtitles are fine, however, when playing it on the tv, only the top half of the words are visible. Any idea why?

    I added subtitles to a movie clip using the ticker tape option. When viewing on the iMac, the words are visible, however, when playing it in the tv, only the top half of the words are visible. Does anyone know why?

    I would agree with Keith Barkley, it may be the TV Safe Area. You can see what spots might be blocked out or cut off by going to iDVD and opening the original DVD project, under the View Menu > Show TV Safe Area. If your title gets cut off by the cropping rectangle displayed, that may account for the cut-off.

  • At home I have wi fi and want to set up an air traveller express so it works with my Ipad ina a hotel room when connected to an ethernet cabel. The instructions are not good any ideas?

    I have just bought an air traveller express and need to set up to work with my Ipad2 when connected to an ethernet cable ina hotel,
    At home I have wi fi and a cabled PC. The express instructions are'nt helping me to know how to set it up. Any ideas please?

    Nigel123 wrote:
    I have just bought an air traveller express
    Do you mean an Apple AirPort Express?

Maybe you are looking for

  • Consistent use of ProRes422LT

    I have had no issues using ProRes 422 throughout FCP (7.0.3) wherever presets are required. I now want to use ProRes422LT but I still end up with ProRes422 in Item>properties on the timeline. If I say "yes" or "no" to "Change sequence settings to mat

  • CRM order details from database and buffer

    Hi, I am working on a scenario where i need to read the order details from buffer and database also to compare the changed values in one of the action class. I have tried with CRM_ORDER_READ and CRM_ORDER_READ_OW. CRM_ORDER_READ is giving the details

  • How to get Receiver Id in EDI message

    I'm sending Invoic(810) from SAP to coustomer's.For each customer I have different receiver Id in EDI. How to handle this in XI. Thanks in advance.

  • Links List iView: Hiding the "Organize Entries" Command

    Hi all! I am using the Links List iView to display some corporate links. This iView shows an "Organize Entries" control to update the list by default. However, in my requirement, i need to hide this command from the end user. I have taken a look on t

  • Trying to download creative cloud

    Every time i try downloading creative cloud it pops up error code 205 i have no idea why cany someone please help?