End of stream problem

hi all
im having some problems with finding the end of an input stream. Basically im trying to read from a stream and then write the stream to the text box. But i can figure when the end of the stream is. The read method im using returns an int not a byte, otherwise id use:
if(input == -1) return;
but because of it being an int it never returns -1 like a byte would so im having trouble. Here's the code.
try
      int i = socketInput.read();
      while(true)
        if (i == -1) return;
        out.write(i);       
         i = socketInput.read();
    catch(IOException ioe){}any help? thanks.
btw, i know the coding probably sucks, im still trying to get my head round it.

From the InputStream java doc concerning method read():
read
public abstract int read()
                  throws IOException
    Reads the next byte of data from the input stream. The value byte is returned as an int
    in the range 0 to 255. If no byte is available because the end of the stream has been
    reached, the value -1 is returned. This method blocks until input data is available, the
    end of the stream is detected, or an exception is thrown.Int is find for the return of -1, but if you are really using a socket, that will probably not return -1 until the socket is closed. In fact, it will block if nothing is available. Try using available() to see if anything is there to read before doing the read(). I don't know if you can assume that, if the number of bytes available is zero, that you are done.
� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • New Radio Station & Streaming Problems

    I have added my favorite Public Radio station to my iTunes library, but I can not get it to connect. It shows up in the library as a radio station, but nothing happens when I click on the play button.
    In addition, I'm having trouble with all the radio stations I've tried that were already in the iTunes folder. I've tried changing the streaming buffer size in preferences, but the network keeps stalling and needing rebuffering, regardless of the streaming buffer size I choose.
    PowerBook PowerPC G4   Mac OS X (10.4.2)   Other computer is iMac, OS X v.10.3.9

    I single file in a playlist repeats constantly for me (just tried it - don't usually have playlists for single items), but I have never tried using repeat on an audio stream. I expect the repeat doesn't work with streams because iTunes never gets an end-of-file notification which would then tell iTunes to start again at the beginning - but that is just a guess.
    What happens if you open the stream in Quicktime? If the stream is in iTunes library, you can open it's Get Info box, click on Edit URL on the summary tab, and you can then copy the address to paste into Quicktime's Open URL. If the stream is one on the default iTunes Radio list, drag it into your Library and you can then click on the Edit URL button to copy the address. iTunes an Quicktime are not exactly the same, so you may get different results. You could also try VLC Player". Testing streams in another player may help you identify if it is really iTunes at fault.
    I usually don't have streaming problems, although I rarely have a stream on longer than 2 or 3 hours at a time and I think about 5 hours is the longest I've had a stream running.

  • Visual admin login (end of stream error)

    If I logon to visual administrator I am getting the following error during connection time(12%)
      Unable to logion to Hostname:
    End of stream reached unexpectedly during input from socket( 168.15.5.2 ,port =50004,localport =2825)
    beacuse of this problem I am not able to log onto visual adminstrator.
    I would be grateful for all your suggestion

    Hi,
    Check your server0.log file I think there is some issue with j2ee_admin password.Any ways check that log file it gives you enough info.
    Regards,
    Vamshi.

  • Error Message: IMW-00005: end-of-stream;

    I have a BC4J JSP application (Jdev 9.02) that allows images to be uploaded and stored internally as ORDSYS.ORDIMAGE type. I need to record the file name and directory of the original upload file. This data does not appear to be available through the default HtmlServices.getRequestParameters method. I have amended the code to make use of OrdHttpUploadRequest but as soon as I attempt to parse the data I get the following error:
    OrdHttpUploadRequest ordRequest = new OrdHttpUploadRequest(request);
    if (ordRequest.isUploadRequest()) {
    ordRequest.parseFormData();
    OrdHttpUploadFile mFile = ordRequest.getFileParameter("ImgImage");
    Error Message: IMW-00005: end-of-stream; client terminated request (or invalid Content-Length)
    Is there a workaround for this problem.

    You got this error because your code tried to parse the multipart request again. The multipart request had already been
    parsed by BC4J HtmlServices before your code. It can only be parsed once.
    There is no way to get OrdHttpUploadRequest object in user's code. This is a BC4J bug. We have fixed it in JDev903.
    To work around it, you may try the following:
    In DataHandlerComponent.jsp:
    <jbo:OnEvent name="update">
    <jbo:Row id="myrow" datasource="ds" rowkeyparam="jboRowKey" action="Update" />
    <%
    OrdImageDomain image = (OrdImageDomain) myrow.getAttribute("ImgImage");
    OrdHttpUploadFileSource fileSource = (OrdHttpUploadFileSource) image.getContentSource();
    OrdHttpUploadFile file = fileSource.getOrdHttpUploadFile();
    String filename = file.getOriginalFileName();
    %>
    richard

  • End of Stream

    Hi,
    How can I send an "End of Stream" down a stream without closing it?
    Cheers
    Rob

    No doesn't seem to work in this case. I'm reading the stream with an app I've written to use the nio package's selectable channels. Below is the read method I'm using. The problem is that clientSocket.read(buff) is never returning -1 even though I can see that all the bytes have been read.
    Basically it does the first pass, reads all the bytes into the buffer and then just hangs around waiting for the channel's interest ops to come back to OP_READ, but they never do. I'm sure I must be reading the socket or checking the buffer badly but I can't figure out where.
         private boolean read(SelectionKey key) throws IOException {
              int read =clientSocket.read(buff);
              if( read==-1) {
                   buff.flip();
                   in = charset.decode(buff).toString();
                   System.out.println("Switch to write");
                   return true;
              } else {
                   System.out.println("More read ["+read+":"+buff.remaining()+"]");
                   key.interestOps(SelectionKey.OP_READ);
                   return false;
         }

  • "End of Stream has been reached"

    "End of Stream has been reached"
    I get this message when trying to preview my project. I started this project in Encore DVD 1.5, and I get this error message when I'm editing it in the new Encore DVD 2.0 trial.
    Thanks in advance.

    Hello Jesse,
    I found a solution for you !
    I had the same problem : opening in encore dvd 2.0 trial a project made in 1.5. Trying to preview the menus, got the "end of stream" error.
    In my project, the problem was a sound, used on a menu, that was bad encoded : it was in 44.1 Khz instead of the "dvd standard" 48 khz. When previewing the menu in 1.5, encore dvd did a transcode. But the 2.0 version seemed to have problems with the transcoded sound, because I replaced it in the menu with a upsampled 48khz sound (out of encore, with a sound software) and, MIRACLE ! it works !!!
    My analysis of the problem is : when you preview a menu, Encore loads in the RAM the whole menus of your projects. Therefore, if you have only one menu bugging, it will affect all your preview !
    I recommend you to check that all you assets are to the dvd standards, and if it still bugs, try to delete the transcodes (in the folder : x:\your project\Sources\Transcodes OR on the C:\Documents and Settings\USER NAME\Local Settings\Temp\Sonic\Transcodes)

  • Minecraft server end of stream

    Haus-MacBook-Pro:Bukkit hau$ java -Xms1024M -Xmx1024M -jar craftbukkit.jar nogui
    161 recipes
    17 achievements
    12:02:16 [INFO] Starting minecraft server version Beta 1.8.1
    12:02:16 [INFO] Loading properties
    12:02:16 [INFO] Starting Minecraft server on 5.119.42.179:25564
    12:02:16 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-1131-g86b7fa8-b1337jnks (MC: 1.8.1)
    12:02:18 [INFO] MLog clients using java 1.4+ standard logging.
    12:02:18 [INFO] Preparing level "world"
    12:02:18 [INFO] Default game type: 0
    12:02:18 [INFO] Preparing start region for level 0 (Seed: 2252740922174884433)
    12:02:19 [INFO] Preparing spawn area: 4%
    12:02:20 [INFO] Preparing spawn area: 48%
    12:02:21 [INFO] Preparing start region for level 1 (Seed: 2252740922174884433)
    12:02:21 [INFO] Preparing spawn area: 0%
    12:02:22 [INFO] Preparing spawn area: 60%
    12:02:25 [INFO] Loaded Essentials build 2.6.4 by: Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits
    12:02:25 [INFO] Essentials: Using config based permissions. Enable superperms in config.
    12:02:25 [INFO] Loaded EssentialsChat build 2.6.4 by: essentials team
    12:02:25 [INFO] Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
    12:02:26 [INFO] Loaded EssentialsProtect build 2.6.4 by: essentials team
    12:02:26 [INFO] Loaded EssentialsSpawn build 2.6.4 by: essentials team
    12:02:26 [INFO] Server permissions file permissions.yml is empty, ignoring it
    12:02:26 [INFO] Done (0.837s)! For help, type "help" or "?"
    12:02:49 [SEVERE] java.lang.NullPointerException
    12:02:49 [SEVERE]     at net.minecraft.server.NetworkListenThread.a(SourceFile:63)
    12:02:49 [SEVERE]     at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:154)
    12:02:49 [SEVERE]     at net.minecraft.server.Packet254GetInfo.a(SourceFile:16)
    12:02:49 [SEVERE]     at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    12:02:49 [SEVERE]     at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:46)
    12:02:49 [SEVERE]     at net.minecraft.server.NetworkListenThread.a(SourceFile:94)
    12:02:49 [SEVERE]     at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:471)
    12:02:49 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    12:02:49 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
    12:02:49 [INFO] /5.119.42.179:54177 lost connection
    >

    Hello Jesse,
    I found a solution for you !
    I had the same problem : opening in encore dvd 2.0 trial a project made in 1.5. Trying to preview the menus, got the "end of stream" error.
    In my project, the problem was a sound, used on a menu, that was bad encoded : it was in 44.1 Khz instead of the "dvd standard" 48 khz. When previewing the menu in 1.5, encore dvd did a transcode. But the 2.0 version seemed to have problems with the transcoded sound, because I replaced it in the menu with a upsampled 48khz sound (out of encore, with a sound software) and, MIRACLE ! it works !!!
    My analysis of the problem is : when you preview a menu, Encore loads in the RAM the whole menus of your projects. Therefore, if you have only one menu bugging, it will affect all your preview !
    I recommend you to check that all you assets are to the dvd standards, and if it still bugs, try to delete the transcodes (in the folder : x:\your project\Sources\Transcodes OR on the C:\Documents and Settings\USER NAME\Local Settings\Temp\Sonic\Transcodes)

  • IMW-00005:end-of-stream

    Hi,
    I did all the necessary to use intermedia into my web/struts application using jdeveloper 9.0.5.
    I installed intermedia to Oracle Database without problem then I build my project into jdeveloper.
    The exception occured on this line when parsing multipart data:
    OrdHttpUploadFormData formData = new OrdHttpUploadFormData( request );
    formData.parseFormData(); //Exception is here
    the error message is :
    oracle.ord.im.OrdHttpUploadException: IMW-00005: end-of-stream; client terminated request (or invalid Content-Length)
    Any help ?
    Thank you

    I have the same problem on JRun 3.0.

  • Messaging Server 4.15 and End-Of-Stream messages

    My SMTP log has an entry "[28/Mar/2002:14:26:01 -0700] mail smtpd[364]: Network Notice: Client End-Of-Stre
    am from 127.0.0.1 [127.0.0.1]" that appears over and over again. They appear every 10 minutes.
    The mail server appears to be sending and recieving mail properly. Clients appear to be working as well both with HTTP and POP3.
    Is this a normal message or is indicative of some type of problem?

    it's a normal message. What you're seeing the the stored process connecting to the smtp port to make sure it's responding. It's not sending any data down so smtp is closing the connection and reporting the "end of stream". The giveaway is that the connection is coming from the loopback address (127.0.0.1)

  • DataDirect DB2 drivers (jdbc) exception: end of stream on read

    Using the DataDirect version 3.4 drivers against V8.1 of DB2...
    Having trouble establishing a connection to DB2 with the com.ddtek.jdbc.db2.DB2Driver class:
    SQLException: [DataDirect][DB2 JDBC Driver]End of stream was detected on a read.
    The url is as follows:
    jdbc:datadirect:db2://sadbarkprodtest2:6789;databaseName=INFRA
    Used the default JDBC port number (which has been verified) and the user/password are set as arguments in the Connection initialization. Not sure why the exception is being thrown. Has anybody use had the same problem?
    /Matthew Young

    Running DB2 V8.1.5 on a Solaris machine (sparc)...
    On the client side I am using jdk 141_03 from Bea and the DataDirect JDBC drivers (version 3.4). Sample code looks as follows:
    public class Test {
      private String url = "jdbc:datadirect:db2://sadbarkprodtest2:6789;databaseName=INFRA";
      private String userid = "xxx";
      private String password = "xxx";
      public void connect() {
        try
          Class.forName("com.ddtek.jdbc.db2.DB2Driver");
          connection = DriverManager.getConnection(url,userid,password);
        catch (SQLException sqle) {
           sqle.printStackTrace();
        catch (Exception e) {
           e.printStackTrace();
      public static void main(String[] args) {
        Test test = new Test ();
        test.connect ();
    }I get the same "End of stream was detected on read" error with the Bea DB2 7.*,8.* drivers. Assuming the problem has something to do with the version of DB2.
    / thanks - Matthew

  • VA - End of stream is reached unexpectedly during input from Socket

    Hi All,
    When I try to connect to Visual Administrator I get the following error:
    "End of stream is reached unexpectedly during input from Socket"
    Administrator user is not locked (I can log on with this user to the portal).
    I tried to create Direct Connection and connect using other user with administrator permissions/roles - didn't help
    I tried to change administrator password in secure store  - didn't help either.
    If I restart the server, I can connect right after the restart (so restart does release something...)
    Portal version is: EP7 SP11.
    The machine is a test machine
    (Windows 2003 under VMWare with just 1.5MB memory).
    I have more than 5GB free in System/Portal partitions.
    My other systems are "real" machines with 2GB ram and I don't have this issue in other systems.
    Could it be memory problem?
    My settings are exactly as described in note 957355
    Regards,
    Omri

    Hi Mike,
    I cannot attach the log, but this is what I mainly get:
    <i>Cannot create new RemoteLoginContext</i>
    <i>#
    #1.5#C0002A00018800000000000101C6866D0004347EF23B0728#1183619741321#com.sap.engine.services.adminadapter.gui.tasks.LoginTask##com.sap.engine.services.adminadapter.gui.tasks.LoginTask#######Thread[Thread-2,5,main]##0#0#Error#1#/System/Server/VisualAdministrationTool#Java###Error while trying to login to <server>: Cannot create new RemoteLoginContext.
    [EXCEPTION]
    #1#com.sap.engine.services.security.exceptions.BaseLoginException: Cannot create new RemoteLoginContext.
         at com.sap.engine.services.security.remote.login.RemoteLoginContext.<init>(RemoteLoginContext.java:71)
         at com.sap.engine.services.adminadapter.gui.tasks.LoginTask.connectAction(LoginTask.java:96)
         at com.sap.engine.services.adminadapter.gui.tasks.LoginTask.run(LoginTask.java:79)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: java.io.EOFException: End of stream is reached unexpectedly during input from Socket[addr=/<ip>,port=50004,localport=4300]
         at com.sap.engine.services.rmi_p4.Connection.run(Connection.java:420)
         ... 1 more
    </i>
    Meanwhile, I opened OSS message.
    Regards,
    Omri

  • IMW-00005: end-of-stream  on JDEV 9i

    I'm trying to make an application using jdeve9i
    i'm working on windows2000 server
    the application simply takes a name and file using a file input from a jsp and then the jsp submits to another jsp that is suppost to insert a record in the dataabse using the data provided in the request
    the first jsp has the following code
    <jbo:FileUploadForm action="Docsave.jsp" >
    DocName: <INPUT TYPE="TEXT" NAME="docname"><br>
    File: <INPUT TYPE="FILE" NAME="file"><br>
    <INPUT TYPE="SUBMIT" TEXT="SUBMIT">
    </jbo:FileUploadForm>
    while the second one takes it and
    preform the following
    OrdHttpUploadFormData formData = new OrdHttpUploadFormData( request );
    formData.parseFormData();
    docname = formData.getParameter( "docname" );
    OrdHttpUploadFile photo = formData.getFileParameter( "file" );
    img = new OrdDocDomain();
    img.setContentSource(new OrdHttpUploadFileSource(photo));
    The problem comes in teh method formData.parseFormData();
    this method throws the error
    oracle.ord.im.OrdHttpUploadException: IMW-00005: end-of-stream; client terminated request (or invalid Content-Length)
         int oracle.ord.im.OrdMultipartInputStream.read().....
    please help its so urgent to end my application today

    I am using jdev version 9032 and oc4j version 9031 .
    Basically I have got a servelt that does the upload and then calls a jsp which has ApplicationModule tag in it at the top.
    So when it calls the jsp , I get this error .
    The code of upload :
    try {
    OrdHttpUploadFormData fd = HtmlServices.getOrdFormData((HttpServletRequest)request);
    // the 2 lines below call a bean which saves the data to database .
    PropertySetter.setProperties(submissionsBean, fd);
    submissionsBean.save();
    am.getTransaction().commit();
    fd.release();
    dispatcher = request.getRequestDispatcher("casehome.jsp");
    dispatcher.forward(request,response);
    }

  • Indicating the end of stream

    Iam sending bytes over a socket to a client machine. What is the best way of telling the client machine that the end of stream has reached?
    I mean is it ok if I write all data to the stream and close the stream - so that even if the client is reading at a much slower rate, it can still get all the data written to the stream by the server(the underlying network layer ensures this?)?
    Browsed the socket prog forum.. but dint get an appropriate answer....

    guys, problem not solved :
    Let's say the client reads much faster than what the server writes.
    Obviously, the client reads will block till data is available.
    So, in this case, how does the client know if the server is done with writing all the data(calling read in the client even after server has terminated doesn't throw an exception) or if it's going to write the data a bit later?
    Is my question valid ? If yes, two options:
    #1 send no. of bytes to be transmitted from the server to the client, so the client knows how many bytes to expect
    #2 Put a reasonable timeout on the client
    would they work?

  • NIO: Detection end-of-stream

    Hi group,
    I'm writing a simple HTTP client based on NIO. Setting up a connection and sending a request all goes well. Reading the response also works, but not as expected. I would expect to receive a -1 value on the SocketChannel.read(buffer) to indicate end of stream. However, if the last chunk of data is read this method returns the size of this chunk (and not -1) and the SocketChannel.read(buffer) is not called anymore until the server closes the connection. If the timeout is not set or is set with a large value my application waits for a long time to continue.
    How do I detect the end of the (HTTP Response) stream without waiting for the connection to be closed by the server?
    Regards,
    Erwin.

    ejfdebruijn wrote:
    I'm writing a simple HTTP client based on NIO. Setting up a connection and sending a request all goes well. Reading the response also works, but not as expected. I would expect to receive a -1 value on the SocketChannel.read(buffer) to indicate end of stream. However, if the last chunk of data is read this method returns the size of this chunk (and not -1) and the SocketChannel.read(buffer) is not called anymore until the server closes the connection. If the timeout is not set or is set with a large value my application waits for a long time to continue.
    How do I detect the end of the (HTTP Response) stream without waiting for the connection to be closed by the server?By interpreting the data.
    Read the HTTP header, get the Content-Size header field's value, and limit() your buffers accordingly.
    @see the HTTP specs.
    A client-server connection might be used for more than one exchange of messages, hence it is left open. You could try passing Connection: close in the request header, but it's not guaranteed to work across the field.
    You'd have the same problem with the old IO, btw.

  • End Of Stream while reading from HttpServletRequest's inputstream

    Hi,
              I am trying to read from input stream got by invoking HttpServletRequest.getInputStream(). The first time it is successful until I read all data(End of stream). The second time I get End Of Stream on the very first read. The actual stream instance is of type weblogic.internal.servlet.ServletInputStreamImpl. Has anyone faced similar problems.
              

    is it correct that before changing the direction of communication (read to write and vica-versa) it is sent "end-of-stream" signal?No it is not correct.
    my colleague says that "end-of-stream" in normal is sent every time I switch direction.There is no such thing as 'switching direction' in TCP. It's a full-duplex protocol: you can send and receive at the same time. Therefore there is no such thing as a direction switch; therefore there is no result of a direction switch; therefore your colleague is talking through his hat. Your colleague should research and test his beliefs before handing out advice.
    In TCP, EOS is received when the peer has closed the socket, or called Socket.shutdownOutput(), and not before. As your tests have already revealed.

Maybe you are looking for

  • Problems converting Powerpoint/Excel to PDF, line thickness issue

    Hi, I have been having problems with how lines in excel come out when printing using Adobe PDF or PDF Creator.  In both cases the thickness of lines, while consistent in excel, comes out completely random in PDF.  My PDFs go to clients and appearance

  • Sound on DVD Scratchy

    I just burned a DVD from a 4 minute movie that I made. The movie was just pictures with music behind it. The video was fine but the audio is all scratchy (this has happened on the last couple that I burned). The song was a purchased song from iTunes.

  • Service details

    Hi , We developed a report for displaying serice number for work orders. It is working fine for work order with only one servive entry sheet . But when a work order consists of multiple operations with multiple service entry sheets it is not picking

  • AQ adapter configuration in OSB.

    Hi, 1)I have developed a OSB service that dequeues the message from the queue and calls a stored procedure. 2)I used a non XA datasource for AQ adapter. 3) I could see that the message is going to processed state only after we get the response from P

  • Cannot open backup files from Seagate drive

    My original plan was the backup my files before upgrading my iMac from OS Tiger 10.4 to the current version of 10.6.3 (now .8 after updates). I bought a Seagate external drive to backup my personal documents (.doc, .jpg's, .pdf's) on Tiger. After suc