Inputstream limitation??

hi. i have a server in java and a C# client. they are communicating through sockets. however when i tried to sent to send a image (a few mb)
the server would only received 7300 bytes.
some parts from my codes
     int servPort= 3333;
     ServerSocket     servSock= new ServerSocket(servPort);
     int i= 0;
     byte[] byteBuffer = new byte[BUFSIZE];     
     for (;;){                                                                 // Run forever, accepting and servicing connections
Socket     clntSock     = servSock.accept();     // Get client connection
System.out.println( "Handling client at "+clntSock.getInetAddress().getHostAddress() +
" on port " + clntSock.getPort() );
InputStream          in          = clntSock.getInputStream();
OutputStream     out          = clntSock.getOutputStream();
OutputStream     out1     = new FileOutputStream("outpic.jpg");
               try{
                    System.out.print( " available: " + in.available()  + "\n"  );
                    i = in.read( byteBuffer );any advice is appreciated.thanks in advance

sorry for not posting my full codes
public class TCPServer {
  private static final int BUFSIZE = 1024*20;   // Size of receive buffer
  public static void main(String[] args) throws IOException {
    int                    servPort     = Integer.parseInt("4000");
    // Create a server socket to accept client connection requests
    ServerSocket     servSock     = new ServerSocket(servPort);
    int                    recvMsgSize;               // Size of received message
    byte[]               byteBuffer     = new byte[BUFSIZE];     // Receive buffer
    for (;;) { // Run forever, accepting and servicing connections
      Socket          clntSock     = servSock.accept();     // Get client connection
      System.out.println("Handling client at " + clntSock.getInetAddress().getHostAddress() + " on port " + clntSock.getPort());
      InputStream     in     = clntSock.getInputStream();
      OutputStream     out     = clntSock.getOutputStream();
      recvMsgSize = in.read(byteBuffer);
      System.out.println( "recvMsgSize: " + recvMsgSize );
      clntSock.close();  // Close the socket.  We are done with this client!
}

Similar Messages

  • InputStream/url limitations? First 20 requests complete, others don't

    I am having an issue where the first 20 requests for photos on a intranet webserver is completing, but the next 20 have approximately a 30-40 second delay before it is completed. The first set comes back in under a second.
    When I create an html page with 30 pictures from the same server, all of them come back at the same time. (not sure if this is a valid test).
    So I have a loop that requests images from a server, approximately 4kb-10kb each.
    Here is the loop:
    private void getRecentPictures()
              int count = recentNames.size();
              String[] rdn = new String[count];
              recentNames.toArray(rdn);
              int i = 0;
              while(i < count)
              addImage(rdn);
              i++;
    And here is addImage.private void addImage(String name)
              URL url;
              Image image = null;
              try {
                   userNameVector.addElement(name.toUpperCase());
                   url = new URL("http://www.myintranet.net/photos/"+name+".jpg");
                   InputStream is = url.openStream();
                   try{
                   image = new Image(Display.getCurrent(), is);
                   is.close();
                   int width = image.getImageData().width;
                   int height = image.getImageData().height;
                   double newWidth = 0;
                   double newHeight = 75;
                   double difference = newHeight/height;
                   newWidth = width*difference;
                   Image scaledImage = new Image(display,image.getImageData().scaledTo((int)newHeight,(int)newWidth));
                   image = scaledImage;
                   catch (Exception e) {
                        image = backupImage;
              } catch (Exception e) {
                   image = backupImage;
         imageVector.addElement(image);
         }I am not sure if this is a server issue (the server admin says he doesn't think any such limitations are in place), or a Java issue, or a coding issue.  Any suggestions?  I am seeing one issue with the way I am closing the input stream in the try statement, it might never get executed.
    Edited by: sarcasteak on Mar 11, 2010 7:28 AM
    Edited by: sarcasteak on Mar 11, 2010 7:37 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    alexxzius wrote:
    I would say thats a server issue. Some websites block access to a web-crawling programs if too much information is lifted from them. You could have a separate executable which reads an image and send the output to the main program. I used this approach in several web-crawling programs.The server admin ran a test and was able to pull back all the pictures on the server in one call, close to 2000. He is also able to get 50 pictures in 1 second or less. Through which means, I am not sure yet.
    Not sure why I used that mess of a try/catch up there. Here is the updated method, still same result.
    private void addImage(String name)
              URL url;
              Image image = null;
              userNameVector.addElement(name.toUpperCase());
              InputStream is = null;
              try{
                   url = new URL("http://url/photos/"+name+".jpg");
                   is = url.openStream();
                   image = new Image(Display.getCurrent(), is);
                   int width = image.getImageData().width;
                   int height = image.getImageData().height;
                   double newWidth = 0;
                   double newHeight = 75;
                   double difference = newHeight/height;
                   newWidth = width*difference;
                   Image scaledImage = new Image(display,image.getImageData().scaledTo((int)newHeight,(int)newWidth));
                   image = scaledImage;
                   catch (Exception e) {
                        image = backupImage;
                   finally{
                        try {
                             if (is!=null)
                             is.close();
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                   imageVector.addElement(image);
         }After 3rd edit >>>I'm retarded, I'll get this right eventually.. closed stream in finally.
    Edited by: sarcasteak on Mar 11, 2010 8:06 AM
    Edited by: sarcasteak on Mar 11, 2010 8:08 AM

  • Java.rmi.NoSuchObjectException with custom InputStream/OutputStream

    I'm experiencing a strange problem here...and have spent the night digging for an answer,
    but I don't see any...
    I am using a custom client/server socket factory, which works great until I return my
    custom In/Out streams from the custom Socket. I can return a BufferedInputStream
    wrapping the socket's InputStream, but if I write a subclass BufferedInputStream
    (and override no methods) I get the NoSuchObjectException...
    any ideas?
    public class BInputStream extends java.io.BufferedInputStream {
      private InputStream in = null;
      public BInputStream(InputStream in) {
        super(in);
        this.in = in;
    }

    What I am trying to do (and have done with the minor limitation that I cannot use
    custom streams to compress the RMI traffic...) is create a totally transparent proxy
    for RMI services.
    The Proxy object is for any Remote object. A Proxy is returned to the client
    containing a Remote Invoker that is called by the Proxy's InvocationHandler.
    Since this is for a known environment, there is no need for dynamic class loading,
    so the JVMs must all have the classes to talk to one another...
      A <---> B <---> CI want to, now, compress the A <--> B link, because it is over a saturated link, and
    a cursory look at the actual data tells me I can compress 300k, which is a standard
    transaction size (after pruning classpath entries from the clients), to around 40k
    (conservative estimate). Obviously, this is a huge improvement in any environment,
    but an especially appealing one considering the fact that this link slows, literally, to
    a crawl at times. I already have the inflate/deflate streams worked out as far as I can
    test them, so all I need to do is get past this current stumbling block and test the
    compression bits in an environment more representative of the deployment env.
    Anyway, that's the highest level goal :-)
    So, a question...to confirm what I believe I found earlier that led me into this bowl
    of noodles (really, it's not that bad, except that I can't debug the code once
    it wanders off into RMI land, which may indicate a problem in my design :-P)...
    [after some more time poking around to make sure I'm not asking a stupid
    question]
    It seems my spaghetti (the exporting of the Invoker inside of the InvocationHandler)
    is necessary for the transparency I desire. As it turns out, I know enough now to
    find useful information from google on this subject :-) That's some progress!
    It seems springframework has something exactly like the server half of my
    system, so I'm gonna take a look at that as I wind this day down.
    cheers.
    b

  • Needed a code for Creating a Log File in java so that its size is limited

    Hi
    I need the code for developing a log file using threads so that the log file size is limited
    and if the size of the log file is increasing above 1Mb,another log file has to be created automatically and the log have to be printed into that new file.
    Thanks in advance

    package cms.web.log;
    import java.io.*;
    import java.util.Calendar;
    import cms.web.WebUser;
    *     Log is generated by JEditor 1.0.0
    *     @Project      : cms
    *     @Version      : 1.0.0
    *     @Created date : 11:07:40  PM Thursday, 25/07/2002
    *     @Author       :
    *     @Organization :
    *     @Copyright    : (c) 2002
    *     An utility class used to write information, especially error messages, to
    *     log file so that they can be viewed at later time by administrators.
    *     Extra information such as date & time they occures & where they are thrown...
    *     are automatically included and append to the end of log file.
    *     Log files will increase with the format "name_n" where n is file counter
    public class Log implements Serializable
          *     logs marker
         static final String START= "\n\0";
          *     parent directory that contains log files
         private static File parent;
         private PrintStream out;
         private String name;
          *     to count how many log for the current stream
         int counter;
          *     maximum number of logs for each log file
         int max;
         public static void init(File parent)
              if (!parent.exists())
                   parent.mkdirs();
              Log.parent= parent;
         public Log(String name, int max)
              this.name= name;
              this.max= max;
              file= getLastFile();
              counter= countLogs(file);
              out= openStream(file);
         public synchronized void appendLog(String log)
              if (log == null || log.length() == 0)
                   return;
              count();
              try {
                   out.println(START+ counter+ " | "+ getCurrentTime()+ " | "+ log);
                   out.flush();
              } catch (Exception e) {}
          *     Append the given log to log file.
         synchronized void appendLog(String msg, WebUser user)
              if (msg == null || msg.length() == 0)
                   return;
              count();
              try {
                   out.println(START+ counter+ "----------------------------------------------------------");
                   out.println(getCurrentTime());
                   out.println(user != null? "User:"+ user.getFullName(): "User: public user");
                   out.println(msg);
                   out.println("\n----------------------------- end -----------------------------\n");
                   out.flush();
              } catch (Exception e) {}
          *     Append the given exception to log file
         synchronized void appendLog(Throwable error, WebUser user)
              if (error == null)
                   return;
              count();
              synchronized (out)
                   try {
                        out.println(START+ counter+ "----------------------------------------------------------");
                        out.println("Exception occured at "+ getCurrentTime());
                        out.println(user != null? "User: "+ user.getFullName(): "User: public user");
                        error.printStackTrace(out);
                        out.println("----------------------------- end -----------------------------\n");
                        out.flush();
                   } catch (Exception e) {}
         private String getCurrentTime()
              Calendar c= Calendar.getInstance();
              return
                   parse(c.get(Calendar.HOUR_OF_DAY))+ ":"+               // 0 --> 23
                   parse(c.get(Calendar.MINUTE))+ ":"+                     // 0 --> 59
                   parse(c.get(Calendar.SECOND))+ " "+                     // 0 --> 59
                   parse(c.get(Calendar.DAY_OF_MONTH))+ "/"+                 // 1 --> 31
                   parse(c.get(Calendar.MONTH)+ 1)+ "/"+                     // 1 --> 12
                   c.get(Calendar.YEAR);                                        // yyyy
         private String parse(int n)
              return n< 10? "0"+ n: ""+ n;
         private void count()
              counter++;
              if (counter> max)
                   incrementFile();
                   counter= 1;
         private void incrementFile()
              File file= null;
              int n= 0;
              while ((file= new File(parent, name+ n+ ".log")).exists())
                   n++;
              if (out != null)
                   out.close();
              out= openStream(file);
         private PrintStream openStream(File file)
              try {
                   if (file.exists())
                        return new PrintStream(new FileOutputStream(file.getPath(), true));
                   else
                        return new PrintStream(new FileOutputStream(file.getPath()));
              } catch (IOException e) {
                   throw new RuntimeException(e.getMessage());
         private int countLogs(File file)
              int count= 0;
              InputStream in= null;
              try {
                   in= new FileInputStream(file);
                   int n;
                   while ((n= in.read()) != -1)
                        if (n == '\0')
                             count++;
              } catch (IOException e) {
              } finally {
                   if (in != null)
                        try {
                             in.close();
                        } catch (IOException e) {}
              return count;
         private File getLastFile()
              File file= new File(parent, name+ "0.log");
              File curr;
              int n= 1;
              while ((curr= new File(parent, name+ n+ ".log")).exists())
                   file= curr;
                   n++;
              return file;
         protected void finalized()
              if (out != null)
                   out.close();

  • Non-blocking socket concurrent limitation?

    I have 2 socket program,one is server side used nio package with JDK1.4.1,the other is client used traditional socket,the client will initialize about 50
    threads trying to connect with server when starting,but only about 15
    can be accepted,these 2 program are runnning in the same computer which
    OS is win2000 professional PC.
    the followd is these code:
    please make a probe with them ,and tell me what's going on?
    server:
    package nio_select_demo;
    import java.io.*;
    import java.net.*;
    import java.nio.*;
    import java.nio.channels.*;
    import java.util.*;
    import java.nio.charset.Charset;
    import java.nio.charset.CharsetDecoder;
    public class Server implements Runnable
    // The port we will listen on
    private int port;
    // A pre-allocated buffer for processing data
    private final ByteBuffer buffer = ByteBuffer.allocate( 16384 );
    private ByteBuffer resBuf = ByteBuffer.allocate( 128 );
    Selector selector;
    AddInfo test ;
    public Server( int port ) {
    this.port = port;
    // for (int i=0; i<threadnum; ++i) {
    new Thread( this ).start();
    test = new AddInfo();
    test.start();
    public void run() {
    try {
    // create a ServerSocketChannel
    ServerSocketChannel ssc1 = ServerSocketChannel.open();
    // ServerSocketChannel ssc2 = ServerSocketChannel.open();
    // Set it to non-blocking
    ssc1.configureBlocking( false );
    // Get the Socket connected to this channel, and bind it
    // to the listening port
    ServerSocket ss = ssc1.socket();
    InetSocketAddress isa = new InetSocketAddress( port );
    ss.bind( isa , 60 );
    // Create a new Selector for selecting
    selector = Selector.open();
    // Register the ServerSocketChannel, so we can
    // listen for incoming connections
    ssc1.register( selector, SelectionKey.OP_ACCEPT );
    System.out.println( "Listening on port "+port );
    int n = 0;
    while (true) {
    // See if we've had any activity -- either
    // an incoming connection, or incoming data on an
    // existing connection
    int num = selector.select();
    // If we don't have any activity, loop around and wait
    // again
    if (num == 0) {
    continue;
    // Get the keys corresponding to the activity
    // that has been detected, and process them
    // one by one
    Set keys = selector.selectedKeys();
    Iterator it = keys.iterator();
    while (it.hasNext()) {
    // Get a key representing one of bits of I/O
    // activity
    SelectionKey key = (SelectionKey)it.next();
    // What kind of activity is it?
    if ((key.readyOps() & SelectionKey.OP_ACCEPT) ==
    SelectionKey.OP_ACCEPT) {
    System.out.println( "accept request" );
    // It's an incoming connection.
    // Register this socket with the Selector
    // so we can listen for input on it
    SocketChannel sc = ((ServerSocketChannel)key.channel()).accept();
    System.out.println( "Got connection from "+sc.socket());
    // Make sure to make it non-blocking, so we can
    // use a selector on it.
    //SocketChannel sc = s.getChannel();
    sc.configureBlocking( false );
    // Register it with the selector, for reading
    sc.register( selector, SelectionKey.OP_READ| SelectionKey.OP_WRITE);
    } else if ((key.readyOps() & SelectionKey.OP_READ) ==
    SelectionKey.OP_READ) {
    //ssc.register(selector , SelectionKey.OP_READ);
    SocketChannel sc = null;
    try {
    // It's incoming data on a connection, so
    // process it
    sc = (SocketChannel)key.channel();
    Socket s1 = sc.socket();
    s1.setTcpNoDelay(true);
    System.out.println( "enter processing data" );
    boolean ok = processInput( key );
    synchronized (selector) {
    key.interestOps(key.interestOps() & ~SelectionKey.OP_READ);
    // If the connection is dead, then remove it
    // from the selector and close it
    if (!ok) {
    key.cancel();
    System.out.println("dead");
    Socket s = null;
    try {
    s = sc.socket();
    s.close();
    } catch( IOException ie ) {
    System.err.println( "Error closing socket "+s+": "+ie );
    } catch( IOException ie ) {
    ie.printStackTrace();
    // On exception, remove this channel from the selector
    key.cancel();
    System.err.println( "Error raised in this socket");
    try {
    sc.close();
    } catch( IOException ie2 ) { System.out.println( ie2 ); }
    System.out.println( "Closed "+sc );
    else if ((key.readyOps() & SelectionKey.OP_WRITE) ==
    SelectionKey.OP_WRITE) {
    System.out.println("Enter Writing");
    String response = new String();
    if((response=this.test.getInfo())!=null){
    resBuf.clear();
    SocketChannel sc = (SocketChannel)key.channel();
    resBuf = ByteBuffer.wrap( response.getBytes("ISO-8859-1" ) );
    sc.write( resBuf );
    synchronized (selector) {
    key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
    // We remove the selected keys, because we've dealt
    // with them.
    keys.clear();
    } catch( IOException ie ) {
    System.err.println( ie );
    private boolean processInput( SelectionKey key ) throws IOException {
    buffer.clear();
    SocketChannel sc = (SocketChannel)key.channel();
    sc.read( buffer );
    buffer.flip();
    String response = new String("response ok");
    // If no data, close the connection
    if (buffer.limit()==0) {
    return false;
    Charset charset=Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();
    CharBuffer charBuffer = decoder.decode(buffer);
    System.out.println(charBuffer.toString());
    System.out.println( "Processed "+buffer.limit()+" from "+sc );
    return true;
    static public void main( String args[] ) throws Exception {
    int port = Integer.parseInt( args[0] );
    System.out.println(port);
    new Server( port );
    cilent:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Client implements Runnable
    private String host;
    private int port;
    private int acport;
    //the size of buffer on how much we write and read per cycle
    private static final int maxWriteSize = 128;
    public Client( String host, int port, int numThreads ) {
    this.host = host;
    this.port = port;
    for(int i =0;i<50;i++){//initialize 50 client threads
    new Thread(this).start();
    public void run() {
    byte buffer[] = new byte[maxWriteSize];
    byte buffer2[] = new byte[maxWriteSize];
    try {
    Socket s = new Socket( );
    InetSocketAddress sa = new InetSocketAddress(host,this.port);
    s.connect(sa);
    System.out.println(s);
    s.setTcpNoDelay(true);
    InputStream in = s.getInputStream();
    OutputStream out = s.getOutputStream();
    for (int i=0; i<maxWriteSize; ++i) {
    buffer[i] = (byte)'a';
    out.write( buffer, 0, maxWriteSize );
    int pause = 500;
    in.read( buffer , 0 , maxWriteSize );
    System.out.println( Thread.currentThread()+" wrote "+maxWriteSize);
    String res = new String ( buffer );
    String res2 = new String ( buffer2 );
    System.out.println( res );
    try { Thread.sleep( pause ); } catch( InterruptedException ie ) {}
    } catch( Exception ie ) {
    ie.printStackTrace();
    System.err.println(ie.getMessage());
    static public void main( String args[] ) throws Exception {
    String host = "127.0.0.1";
    int port = Integer.parseInt( args[0] );
    int numThreads = Integer.parseInt( args[1] );
    new Client( host, port, numThreads );

    I have found the reason!!!
    because of system resource limitation,windows can't afford to maintain
    so many concurrent stream-IO,so some socket will be closed.
    I modified the client side code,adding thes segments to client instantialize
    such as :
    public Client( String host, int port, int numThreads ) {
    for(int i =0;i<1000;i++){
    new Thread(this).start();
    try {
    Thread.currentThread().sleep(100);//give system some idle
    } catch (InterruptedException e) {
    /* ignore */
    then the server can accept more than 1000 client request concurrently.

  • [pppacker] ERROR: Failed to pack public part: Failed to get InputStream fo

    Dear Friends,
                  I have downloaded the ECC_PURCHASEORDER002QR from HU2 system (wadmin)  & saved on Local PC with extension as .xml.
    I have created External Service by picking up this WSDL from Local pc.
    When i try to build this its giving me packing error
    error text
    [pppacker] ERROR: Failed to pack public part: Failed to get InputStream for resource C:\Documents and Settings\chandra.dasari\.dtc\LocalDevelopment\t\8A377BFE144E14E551EDE29FADD14317\classes\com\sap\es_po\extsrv\purchaseorderbyidqueryresponse__in\input\Ns1_parameters$Ns1_PurchaseOrderByIDQueryMessage__sync$PurchaseOrderSelectionByID$Ns1_PurchaseOrderID.class
    We are currently using NWDS v7.0.07 with java SP 12.
    Any pointers to resolve this issue.
    Regards shekar chandra

    just out of curiosity why don't you use the RFC connection instead of web service? you seem to be calling an abap system.
    anyway, just to be sure i guess you mean importing a web service into CAF Core as external service. Right?
    what's the nature of your import parameters and your table definitions?
    See there're limitations using complex types with web services. you have less problems if you're importing RFC into CAF Core. My guess is that you're using complex types in your RFC definition that cause problems when translated into WSDL. Can you try at least to the tutorial 85 "Using RFCs as External Services (Service)" https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b3529fea-0c01-0010-76a5-cf1239e38fd9?

  • Finding hard and soft open file limits from within jvm in linux

    Hi All,
    I have a problem where I need to find out the hard and soft open file limits for the process in linux from within a java program. When I execute ulimit from the terminal it gives separate values for hard and soft open file limits.
    From shell if I run the command then the output is given below:
    $ ulimit -n
    1024
    $ ulimit -Hn
    4096
    The java program is given below:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import java.io.StringWriter;
    import java.io.Writer;
    public class LinuxInteractor {
    public static int executeCommand(String command, boolean waitForResponse, OutputHandler handler) {
    int shellExitStatus = -1;
    ProcessBuilder pb = new ProcessBuilder("bash", "-c", command);
    pb.redirectErrorStream(true);
    try {
    Process shell = pb.start();
    if (waitForResponse) {
    // To capture output from the shell
    InputStream shellIn = shell.getInputStream();
    // Wait for the shell to finish and get the return code
    shellExitStatus = shell.waitFor();
    convertStreamToStr(shellIn, handler);
    shellIn.close();
    catch (IOException e) {
    System.out
    .println("Error occured while executing Linux command. Error Description: "
    + e.getMessage());
    catch (InterruptedException e) {
    System.out
    .println("Error occured while executing Linux command. Error Description: "
    + e.getMessage());
    return shellExitStatus;
    public static String convertStreamToStr(InputStream is, OutputHandler handler) throws IOException {
    if (is != null) {
    Writer writer = new StringWriter();
    char[] buffer = new char[1024];
    try {
    Reader reader = new BufferedReader(new InputStreamReader(is,
    "UTF-8"));
    int n;
    while ((n = reader.read(buffer)) != -1) {
    String output = new String(buffer, 0, n);
    writer.write(buffer, 0, n);
    if(handler != null)
    handler.execute(output);
    } finally {
    is.close();
    return writer.toString();
    } else {
    return "";
    public abstract static class OutputHandler {
    public abstract void execute(String str);
    public static void main(String[] args) {
    OutputHandler handler = new OutputHandler() {
    @Override
    public void execute(String str) {
    System.out.println(str);
    System.out.print("ulimit -n : ");
    LinuxInteractor.executeCommand("ulimit -n", true, handler);
    System.out.print("ulimit -Hn : ");
    LinuxInteractor.executeCommand("ulimit -Hn", true, handler);
    If I run this program the output is given below:
    $ java LinuxInteractor
    ulimit -n : 4096
    ulimit -Hn : 4096
    I have used ubuntu 12.04, Groovy Version: 1.8.4 JVM: 1.6.0_29 for this execution.
    Please help me in understanding this behavior and how do I get a correct result from withing the java program.

    Moderator Action:
    As mentioned in one of the earlier responses:
    @OP this is not a Java question. I suggest you take it elsewhere, i.e. to a Unix or Linux forum.You posted this to a Java programming forum.
    It is not a Java programming inquiry.
    This off-topic thread is locked.
    Additionally, you have answered your own question.
    Don't bother posting it to one of the OS forums. It will get deleted as a duplicate cross-post.

  • Class to unzip InputStream

    Hi
    Is there an open source library that can help me unzip an InputStream that contains a zip doument and obtain an InputStream for each file inside the zip?.

    Hi
    Thanks for the reply. We tried to use ZipInputStream but we're having problems with zip files that contain files with accented characters. This bug exists in 1.4 and has not been corrected in this JDK. Also, I can't use the class like a simple InputStream, it has some limitation. So I have to load each file in memory and this takes a lot of memory

  • InputStream stops working

    I have an application (such large in scale it would be very impractical to try to make a short example of it) that needs to handle around 2000 input and 2000 output streams coming from 2000 sockets. For each cycle, (being 600ms~) the input streams need to read in 200~ bytes of data, while the output streams need to be sending out anywhere from 1,000,000 to 6,000,000 bytes. When I get around 600 sockets, (1200 streams combined) all working, the InputStreams seem to stop working. Data is being written on the other side of the socket, but in.available() always returns 0, and causes the connection to time out. The results are the same no matter on the same host computer, or using a remote connection.
    My question being, does Java have some limitation that I'm breaking? Or is the problem with my code?
    Edited by: Jadz_Core on Nov 2, 2009 12:49 PM
    Edited by: Jadz_Core on Nov 2, 2009 12:50 PM

    Heres something simmilar to my framework (Not really, its a bad example..) but it might give you some idea whats wrong. At the moment im out of time on this computer, or i would have made it more complete.
    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class Main {
         public static void main(String[] args) throws Exception {
              LocalServer server = new LocalServer(80);
              new Thread(server).start();
    class RemoteClient implements Runnable {
         @Override
         public void run() {
              try {
                   byte[] data = new byte[100];
                   Socket sock = new Socket(InetAddress.getByName("127.0.0.1"), 80);
                   OutputStream out = sock.getOutputStream();
                   InputStream in = sock.getInputStream();
                   while(true) {
                        long start = System.currentTimeMillis();
                        out.write(data);
                        int avail = in.available();
                        for(int i = 0; i < avail; i++) {
                             in.read();
                        System.out.println("Remote cycle");
                        Thread.sleep(200 - (System.currentTimeMillis() - start));
              } catch(Exception e) {
                   e.printStackTrace();
    class LocalServer extends ServerSocket implements Runnable {
         public LocalServer(int port) throws IOException {
              super(port);
              listener = this;
              for(int i = 0; i < CLIENTS; i++) {
                   RemoteClient r = new RemoteClient();
                   LocalClient l = new LocalClient();
                   new Thread(r).start();
                   new Thread(l).start();
                   clients.add(l);
         @Override
         public void run() {
              byte[] dummydata = new byte[LocalClient.bufferSize-10];
              while(true) for(LocalClient client : clients) {
                   try {
                        client.readpacks();
                        client.out.write(dummydata);
                        synchronized(client) {
                             client.notify();
                        System.out.println("Local server cycle");
                   } catch(Exception e) {
                        e.printStackTrace();
         public static ServerSocket listener;
         private final int CLIENTS = 10;
         private ArrayList<LocalClient> clients = new ArrayList<LocalClient>(CLIENTS);
    class LocalClient implements Runnable {
         @Override
         public void run() {
              try {
                   Socket socket = LocalServer.listener.accept();
                   in = socket.getInputStream();
                   out = new BufferedOutputStream(socket.getOutputStream(), bufferSize);
              } catch(Exception e) {
                   e.printStackTrace();
                   System.exit(0);
              while(true) {
                   try {
                        synchronized(this) {
                             wait();
                        writepacks();
                        System.out.println("Local client cycle");
                   } catch(InterruptedException e) {
                        e.printStackTrace();
                   } catch(IOException e) {
                        e.printStackTrace();
         public void readpacks() throws IOException {
              int avail = in.available();
              for(int i = 0; i < avail; i++) {
                   in.read();
         public void writepacks() throws IOException {
              out.flush();
         public InputStream in;
         public BufferedOutputStream out;
         public static int bufferSize = 1000000;
    }

  • Memory limitation on T61

    I have the following Lenovo notebook :
    Product: ThinkPad T61 8898-55G [change]
    Operating system: All [change]
    Original description: T7100(1.8GHz), 1GB RAM, 120GB 5400rpm HD, 14.1in 1024x768 LCD, Intel X3100, CDRW/DVDRW, Intel 802.11abg wireless, Bluetooth, Modem, 1Gb Ethernet, UltraNav, Secure chip, Fingerprint reader, 4c Li-Ion, WinVista Business 32
    I configured my Notebook with a Dual-boot Windowx XP Pro SP3 and Windows Vista Bussines SP1 (32 bit)
    I have 2x 512 MB PC2-5300 667 MHz DDR2 memory inside.
    I read on the Lenovo site :
     Memory Compatibility
    (**) Windows Vista supports up to 4GB maximum memory (32-bit versions of Windows Vista cannot support 4GB). Windows XP supports up to 3GB maximum memory
    I like to update my memory with
    2x 40Y7734 1 GB PC2-5300 667 MHz DDR2 
    or
    2x 40Y7735 2 GB PC2-5300 667 MHz DDR2
    I like to know if I choose for 2x 2GB , will :
    Windows XP SP3 work just fine only it works with 3GB instead of 4GB installed memory
    Window Vista SP1 (32-bit) with the 4GB (even not supported) work stable ?
    Because the prices of 1 GB and 2 GB won't change much nowadays.
    I prefer to use 2x 2GB modules, but I like to know will it work (even with the memory limitation) stable on XP or on Vista
    or it is better/safer to use 2x 1GB modules
    Can anybody help/explain me or advice me ? 
    Electronic
    Message Edited by electronic on 01-16-2009 09:51 PM

    You're better off with 2x2GB, you may decide to run a 64-bit OS someday...and you will notice a difference between 2GB and 3GB when running a 32-bit OS.
    Cheers,
    George
    In daily use: R60F, R500F, T61, T410
    Collecting dust: T60
    Enjoying retirement: A31p, T42p,
    Non-ThinkPads: Panasonic CF-31 & CF-52, HP 8760W
    Starting Thursday, 08/14/2014 I'll be away from the forums until further notice. Please do NOT send private messages since I won't be able to read them. Thank you.

  • Report for Qty Contract and Value Contract with PO release exceeding limits

    Hi All,
    Is there a std report in SAP that the users can use to view Qty and Val Contracts that has exceed in Qty (in case of Qty Contracts) or Val (in case of Val Contracts) ?
    Thanks in advance!

    hi Duke,
    If thinking logically, then there is no report for the same..this may be because you enter the qty or value limits in the contract doc itself....So, when you make the PO for the same, and if the qty or value exceeds the system automatically provides the message..stating that the qty or value has exceeded....
    So, there is no report for the same...
    Hope it helps...
    Regards
    Priyanka.P

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • IPhone limited to 130 apps at a time! 6,200 apps available in app store

    The i phone is limited to nine app screen i notice this when i try to move on to a tenth screen and it would not let me and also when you download a app after all 9 screen are full the app dose not show up but the app store says it is installed apple needs to expand the amount of screen allowed. you then end up having to delete 2 apps download 1 app in able to make the invisible app appear you have to try this one out for your self so you get a better idea of what i mean so it looks like we are limited to 144 apps per iPhone subtract 14 apps that come default on the screen not including the 4 that are on the bar below you are left with 130 apps that can be downloaded and use at a time per i phone that ***** there are over 6,200 apps available in the app store as i type this to you and apple is limiting me to only carry 130 at a time there is somthing worng with this and i think somthing should be done!

    No acutally what that means is most people like myself have to install 30 apps just to get the iphone to do half the things it should have done out of the box. Sure some are wants but most are "need" in order for it to do the things my old palm treo 600 could do, and still there's not copy and past and no video. On top of that they have a stupid 130 limit. I'd love to hear why that is.

  • Writing to file limiting system performanc​e

    Hello,
    I really could use some help with my VI in terms of writing data.  I’ve had a LOT of help optimizing my code and am trying to enhance the performance in terms of data acquisition.  However, it seems as though writing to a data file is really limiting the frequency I can sample at.  I’ve done some research and understand that writing data at every iteration of the while loop and the build array function slows things down.  How would I modify the code so that the array buffer would store maybe 5000 data points before writing to a file, then clearing the array?  That would keep the array size small, as well as reduce the number of times the program is performing the write to file function.  Is there a better way of doing this?  I’m open to any other ideas as well.    
    I am taking data from 14 channels, and would like to sample at 1 kHz each.  The task right now is created within Measurement and Automation Explorer, and the number of samples is at 100.  I also use a buffer indicator, which will generally grow out of control, no matter how much I modify the number of samples and the frequency.  The length of my test can last upwards to 6 hours, so it needs to work that long without crashing.     
    The code and attached subVI’s is attached.  Hopefully it's all there.
    Thanks for your help,
    Alex
    Attachments:
    Test Program.zip ‏295 KB

    Lynn,
    Yea, I'll have to keep on the block diagram size in the future.  Can get unwieldy.
    I tried incorporating the Recent History Buffer example into my code.  I did have a few hang ups, which are giving me some trouble.  Mostly, how do I connect my waveform data to the Buffer VI?  Will I be able to have all my channels connect to this?  Also, ultimately I will have two write to file VI's.  Can the buffer differentiate between which file to write?
    Thanks,
    Alex
    Attachments:
    Instrument Panel V1.1 (Labview 8.0).vi ‏159 KB

  • HT3705 Has anyone any ideas why a Pages file v09 exported from v5 bloats from around 212kb to 5.9mb? I had to export existing template files back from the latest version to v09 due to limited features in latest version.

    Recently updated Pages because of Mavericks update, quickly discovered how limited new version is, exported altered files back to Pages 09 format and re-opened using earlier Pages. In amending to re-save as templates again noticed a 212kb file has bloated to 5.9mb.
    Has anyone any ideas or experience as it will not take long to fill up a 1TB drive at this rate! - I had left behind PC's and MS Office and was reasobaly happy using Pages for business, but it looks like Office for Mac is now going to b eneeded.

    Yes, I opened them all with 5 then re-saved as v5 templates. Then realised other problems with v5 so exported them all back v09 as xxx.pages files. Used some with v09 and noticed they had all increased.
    I just checked again and noticed that the initial v5 saved templates had typically increased from 412kb to 1.1MB (they do have 4 graphics) - then after exporting the templates are 5.9MB in v09 an dthe files are still 412kb.
    I had a similar problem many years ago using RTF files with Word and they kept bloating everytime you edited and saved due to saved or linked graphics?

Maybe you are looking for

  • Windows support software unavailable

    Hello, I couldn't find any topic usefull, so I'm starting a new thread. I have BootCamp 5.0.3 in a MacBook Pro mid 2009. I'm trying to install Windows 7 (64bits, since I've read bootcamp 5 can't use 32), using the bootcamp assistant. My internal dvd

  • Disable clamshell mode via Terminal

    Hi everyone. Is there any way to disable "clamshell mode" and avoid my MacBook Pro waking up seconds after I close the lid?. I always use my MBP17 with a magic mouse, usb hub, external monitor and plugged magsafe but using both screens at the same ti

  • JVM crash in solaris

    java -version java version "1.6.0_29" Java(TM) SE Runtime Environment (build 1.6.0_29-b11) Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode) uname -a : SunOS test-app 5.10 Generic_147440-06 sun4v sparc SUNW,Sun-Fire-T200 hs_err_pid file

  • In new upgrade is there a way to get pics back on caller id

    In the new upgrade is there a way to get pics back on the caller ID when people call you or when you call our rather than just a plain black screen?

  • IPhoto should be in first drop-down for "Open with."

    To edit a new photo, I click "Open with" and get a drop-down menu of apps that does NOT include Iphoto.  I have to click "Other" and scroll down to find Iphoto.  Why isn't Iphoto in the first list?  With the IOS, it should be a preferred app.