Results 1 to 2 of 2
  1. #1
    suthan is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default Connection reset by peer: socket write error

    client program:

    public class demo {
    public static void main(String a[])
    Robot r=new Robot();
    Rectangle rect=new Rectangle(1365,770);
    BufferedImage image=r.createScreenCapture(rect);
    ImageIO.write(image,"JPEG",new File("C:/suthan/image001.jpg"));
    Socket s=new Socket(InetAddress.getLocalHost().getHostAddress() ,52839);
    File f=new File("C:/suthan/image001.jpg");
    OutputStream out=s.getOutputStream();
    DataOutputStream toServer=new DataOutputStream(out);
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    ImageIO.write(originalImage, "jpg", baos );
    byte[] imageInByte=baos.toByteArray();
    //int si=imageInByte.length;
    System.out.println("still conected 1");
    int len=imageInByte.length;
    toServer.write(imageInByte, 0, len);
    System.out.println("still conected 2");

    Server program:

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    byte[] fromClient=new byte[50];
    int i=0;
    ServerSocket s=new ServerSocket(52839);
    System.out.print("server is running"+s.getInetAddress());

    Socket ss=s.accept();
    InputStream str=ss.getInputStream();
    DataInputStream in=new DataInputStream(str);

    Im trying to send image from client to server,but when i convert image into byte array i send it to server Connection reset by peer: socket write error...please stuck in the middle

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Connection reset by peer: socket write error

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. I/O Error: Connection reset...
    By dkennelly in forum Java Servlet
    Replies: 5
    Last Post: 09-17-2010, 03:12 PM
  2. socket write error
    By nemoflich in forum Networking
    Replies: 0
    Last Post: 05-06-2010, 10:09 AM
  3. Replies: 3
    Last Post: 04-13-2010, 03:43 PM
  4. Error in establishing socket connection
    By saso1310 in forum JDBC
    Replies: 2
    Last Post: 05-18-2009, 01:00 PM
  5. Connection reset error in FTP client
    By Waterbottle in forum Networking
    Replies: 0
    Last Post: 03-23-2009, 09:03 AM

Posting Permissions

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