title: java.net.SocketException: sendto failed: EPIPE (Broken pipe) while sending byte[]
body: <p>I am trying to upload video recorded through android mobile. but while sending video as byte[] to server I am getting below error :</p>
  
  <pre><code>  01-20 13:03:18.250: E/SaveMedia-response(4393): java.net.SocketException: sendto failed: EPIPE (Broken pipe)
  </code></pre>
  
  <p>Here is how I am trying to upload video :</p>
  
  <pre><code>        SoapObject request = new SoapObject(
                  HelpMeConstant.WSDL_TARGET_NAMESPACE, "SaveMedia");
          Log.i("SaveMedia-parameter", "Email : " + Email + ", Media : " + Media
                  + "MediaType : " + MediaType + ",MediaExt : " + MediaExt);
  
          MediaAvidance mediainfo = new MediaAvidance();
          mediainfo.EmailId = Email;
          mediainfo.Media = Media;
          mediainfo.MediaExt = MediaExt;
          mediainfo.MediaType = MediaType;
  
          PropertyInfo pi = new PropertyInfo();
          pi.setName("mediainfo");
          pi.setValue(mediainfo);
          pi.setType(mediainfo.getClass());
  
          request.addProperty(pi);
  /*      request.addProperty("EmailId",Email);
           request.addProperty("Media", Media); 
           request.addProperty("MediaType", MediaType);
           request.addProperty("MediaExtn", MediaExt);
  */       
          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                  SoapEnvelope.VER11);
          Log.i("SaveMedia","Serialising..");
          new MarshalBase64().register(envelope);
          envelope.dotNet = true;
          envelope.setOutputSoapObject(request);
          HttpTransportSE httpTransport = new HttpTransportSE(
                  HelpMeConstant.SOAP_ADDRESS);
          Object response = null;
  
          try {
              Log.i("SaveMedia","Calling service..");
              httpTransport.call(HelpMeConstant.SOAP_ACTION + "SaveMedia",
                      envelope);
              Log.i("SaveMedia","getting response..");
              response = envelope.getResponse();
          } catch (Exception exception) {
              response = exception.toString();
          }
          Log.i("response", response.toString());
          return response.toString();
  </code></pre>
  
  <p>and it is sending to a .net web service which is as below :</p>
  
  <pre><code> [WebMethod]
      public string SaveMedia(MediaAvidance avidanceinfo)
      {
          rs = new ResultSet();
          rs = logictask.SaveMedia(avidanceinfo.EmailId,avidanceinfo.Media,avidanceinfo.MediaType,avidanceinfo.MediaExt);
          return rs.isSuccessfull;
      }
  </code></pre>
  
  <p>MediaAvidance :</p>
  
  <pre><code>public class MediaAvidance implements KvmSerializable {
      public String EmailId;
      public byte[] Media;
      public String MediaType;
      public String MediaExt;
  
      public MediaAvidance() {
      }
  
      public MediaAvidance(String EmailID, byte[] Media, String MediaType,
              String MediaExt) {
  
          this.EmailId = EmailID;
          this.Media = Media;
          this.MediaType = MediaType;
          this.MediaExt = MediaExt;
      }
  
      @Override
      public Object getProperty(int arg0) {
          switch (arg0) {
          case GETEMAILID:
              return EmailId;
          case GETMEDIA:
              return Media;
          case GETMEDIATYPE:
              return MediaType;
          case GETMEDIAEXT:
              return MediaExt;
          default:
              return null;
          }
      }
  
      @Override
      public int getPropertyCount() {
          // TODO Auto-generated method stub
          return 4;
      }
  
      @SuppressWarnings("rawtypes")
      @Override
      public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
          switch (index) {
          case 0:
              info.type = PropertyInfo.STRING_CLASS;
              info.name = "EmailId";
              break;
          case 1:
              info.type = PropertyInfo.OBJECT_CLASS;
              info.name = "Media";
              break;
          case 2:
              info.type = PropertyInfo.STRING_CLASS;
              info.name = "MediaType";
              break;
          case 3:
              info.type = PropertyInfo.STRING_CLASS;
              info.name = "MediaExt";
              break;
          default:
              break;
          }
  
      }
  
      @Override
      public void setProperty(int index, Object value) {
          switch (index) {
          case 0:
              EmailId = value.toString();
              break;
          case 1:
              Media = (byte[]) value;
              break;
          case 2:
              MediaType = value.toString();
              break;
          case 3:
              MediaExt = value.toString();
              break;
          default:
              break;
          }
      }
  }
  </code></pre>
  
  <p>At server side MediaAvidance class donot implement <code>KvmSerializable</code> and its method. </p>
  
  <p>I searched for few days and gone through many question in stackoverflow &amp; understood that i am trying to write when the connection is closed and also that it is something related to socket programming. BUT</p>
  
  <p>I don't know how to keep connection alive(probably a solution I think).
  Please help me. </p>
  
  <p>Thanks,
  Sourabh</p>