Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By ketan

Thread: diffrent output/input streams in same socket connection

  1. #1
    ketan is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default diffrent output/input streams in same socket connection

    hello,

    I am trying to send file and then function arguments through same socket connection but in diffrent output streams.( Sending file by fileoutoutstream and arguments by dataoutputstream),,,, but at other end both type of data is being collected in same fileinputstream only and m getting EOFexception ,,, please suggest me how can i resolve this????

    Thanks!

  2. #2
    Join Date
    Feb 2011
    Location
    Ahmedabad
    Posts
    36
    Rep Power
    0

    Default Re: diffrent output/input streams in same socket connection

    EOF exception comes when u have reached at the end of file and still try to read it sol after reaching at the end of file you need to move further so you can catch that exception in catch block as follow


    Java Code:
    try{
    //code to read content
    }
    catch(EOFException e){
    s.o.p.("end of file reached");
    }
    //further processing code
    Hemant Metalia
    cool

  3. #3
    ketan is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: diffrent output/input streams in same socket connection

    thanks for the reply Hemant....
    Yes there is more data to read after EOF but this is my next data,,, i need to collect the data after EOF in new variables,, actually i think both type of data is coming in same packet ,,,, please suggest me how can i send the data in different packets while sending.

    I have handeled the exception but it doesnt resolve my problem,,,

  4. #4
    Join Date
    Feb 2011
    Location
    Ahmedabad
    Posts
    36
    Rep Power
    0

    Smile Re: diffrent output/input streams in same socket connection

    Hi ketan

    as you are using same stream for both file when you transfer data of files in between it so sends the eof character at the end of first file so when you try to receive it it also receives eof character so it throws eofexception so you can handle it at the time of sending data if there is an eof character do not send it into stream.
    Hemant Metalia
    cool

  5. #5
    ketan is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: diffrent output/input streams in same socket connection

    with this at the receiving end, all the data will go in same file as both type of data is goin in same stream,,,, my motive is to send different data in different packets....

  6. #6
    Join Date
    Feb 2011
    Location
    Ahmedabad
    Posts
    36
    Rep Power
    0

    Default Re: diffrent output/input streams in same socket connection

    you can put some separator after every end of data at the time of sending and at the time of receiving you can check for the separator and put it in new variable
    Hemant Metalia
    cool

  7. #7
    ketan is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: diffrent output/input streams in same socket connection

    its done, using ObjectOutputStream class.... sent data after packing in a object.
    Thanks Hemant for ur valuable replies :)
    hemant_metalia likes this.

  8. #8
    Join Date
    Feb 2011
    Location
    Ahmedabad
    Posts
    36
    Rep Power
    0

    Default Re: diffrent output/input streams in same socket connection

    glad to here that your problem is solved enjoy...
    Hemant Metalia
    cool

Similar Threads

  1. Socket, streams and data types?
    By Tomtefaen in forum Networking
    Replies: 0
    Last Post: 01-14-2011, 11:36 PM
  2. Replies: 7
    Last Post: 02-24-2010, 08:00 PM
  3. output streams
    By andre1011 in forum Networking
    Replies: 1
    Last Post: 03-24-2009, 08:18 AM
  4. ObjectInput/Output Streams
    By Rhesus21 in forum Networking
    Replies: 3
    Last Post: 07-30-2008, 01:26 AM
  5. Runtime.exec(), handling input and output streams
    By crookshank in forum New To Java
    Replies: 0
    Last Post: 06-05-2008, 02:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •