Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Socket OutputStream Hanging Up With ImageIO

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Socket OutputStream Hanging Up With ImageIO

    I am trying to send a BufferedImage over a socket OutputStream using the ImageIO write method.

    The problem is, the program always hangs up indefinitely on the write method.

    I would assume it's a problem with the socket's stream, but I've tried writing a single byte of data in place of the image and it worked fine.
    So... I'm not really sure.

    Does anyone know how ImageIO.write works? Does it try to write the whole thing at one time? That could cause the socket or server socket to be overloaded...

    That was it! I set the socket buffer sizes a lot higher and it worked. Sorry... this was a waste of a thread. I didn't think of that before though. Only when I was
    writing this...


    [CODE]
    	public void sendImage(BufferedImage bi) {
    		try {
    			ImageIO.write(bi, "jpg", out);
    		} catch (IOException e) {
    			Popup.errorMessage(e.getMessage(), e);
    			e.printStackTrace();
    		}
    	}
    [/CODE]

    [CODE]
    	public BufferedImage readImage() {
    		try {
    			return ImageIO.read(in);
    		} catch (IOException e) {
    			Popup.errorMessage(e.getMessage(), e);
    			e.printStackTrace();
    			return null;
    		}
    	}
    [/CODE]
    Last edited by bgroenks96; November 6th, 2011 at 01:44 PM.


Similar Threads

  1. Very simple chat program hanging
    By taghack in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 3rd, 2011, 10:37 PM
  2. [SOLVED] universal outputstream
    By beruska in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: October 17th, 2011, 07:26 AM
  3. OutputStream in java
    By god1gracious in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: October 4th, 2011, 02:46 AM
  4. Object Stream Hanging...
    By Ellipsis in forum Java Networking
    Replies: 2
    Last Post: October 22nd, 2010, 07:20 PM
  5. Socket C
    By ighor10 in forum Java Networking
    Replies: 0
    Last Post: June 22nd, 2010, 06:56 AM