title: XDR Encode function
body: <p>I have create, with rpcgen, these two file (.h and .c) with my own two structs (the environment is Linux and the programming language is C).</p>
  
  <p>The two structs are these below (this is the .h file):</p>
  
  <pre><code>/*
   * Please do not edit this file.
   * It was generated using rpcgen.
   */
  
  #ifndef _XDRTYPES_H_RPCGEN
  #define _XDRTYPES_H_RPCGEN
  
  #include &lt;rpc/rpc.h&gt;
  
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  
  struct Request {
      struct {
          u_int data_len;
          float *data_val;
      } data;
      bool_t last;
  };
  typedef struct Request Request;
  
  struct Response {
      bool_t error;
      float result;
  };
  typedef struct Response Response;
  
  /* the xdr functions */
  
  #if defined(__STDC__) || defined(__cplusplus)
  extern  bool_t xdr_Request (XDR *, Request*);
  extern  bool_t xdr_Response (XDR *, Response*);
  
  #else /* K&amp;R C */
  extern bool_t xdr_Request ();
  extern bool_t xdr_Response ();
  
  #endif /* K&amp;R C */
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* !_XDRTYPES_H_RPCGEN */
  </code></pre>
  
  <p>In my main I call <code>#include &lt;rpc/rpc.h&gt;</code> and <code>#include "xdrtypes.h"</code>.Then I want send a Request message to the server with a socket (<code>s</code> is the file descriptor <code>s = socket(...)</code>):</p>
  
  <pre><code>stream_socket_w = fdopen(s, "w"); 
  xdrstdio_create(&amp;xdrs_w, stream_socket_w, XDR_ENCODE);
  
  x.data.data_len = 5;
  x.last = 1;
  x.data.data_val[0] = 5.3;
  x.data.data_val[1] = 2.7;
  x.data.data_val[2] = 8.4;
  x.data.data_val[3] = 2.9;
  x.data.data_val[4] = 1.7;
  
  xdr_Request(&amp;xdrs_w, &amp;x);   
  fflush(stream_socket_w);
  </code></pre>
  
  <p>The problem is that the execution stop at the line <code>xdr_Request(&amp;xdrs_w, &amp;x)</code> and I obtain "<code>Segmentation Fault</code>". Everybody Can Help me please? Thank you very much. </p>