GLX glXQueryVersion returns error of "wrong opcode". Unix socket connection

49 Views Asked by At

The connection to the X server is done with Unix sockets. I can confirm that the server has GLX extension with the following code:

  const char *str_extension = "GLX";
/* X protocol requires requests to be in 4 byte units */
  ssize_t     len       = ((strlen(str_extension + 1) + 3) & ~3; 
  char        pad_str_extension[3 + l];
  rq_q_extension_t  rq = {
   .opcode = X11_OPCODE_QUERY_EXTENSION,
   .len    = 2 + len / 4,
   .len_nm = strlen(str_extension),
  };

  memcpy(pad_str_extension, str_extension, strlen(str_extension));

  rp_q_extension_t  rp;

  if(write(fd, &rq, sizeof(rq)) < (ssize_t)sizeof(rq))
   ERROR;
  if(write(fd, cbf, 3 + l) < (3 + l))
   ERROR;
  if(read(fd, &rp, sizeof(rp)) < (ssize_t)sizeof(rp))
   ERROR;
  printf("GLX present   : %u\n", rp.present);
  printf("\tmajor_code  : %u\n", rp.major_code);
  printf("\tfirst_event : %u\n", rp.first_event);
  printf("\tfirst_error : %u\n", rp.first_error);

The above outputs that extension is present and has 1.4 version. My problem is that the next request fails.

  rq_gxl_q_version_t  rq = {
   .opcode_x11 = glx_base_opcode,
   .opcode_glx = X11_OPCODE_GLX_QUERYVERSION,
   .len        = sizeof(rq_gxl_q_version_t) / 4,
   .major_version = 1,
   .m1nor_version = 4,
  };
  rp_glx_q_version_t rp;

  if(write(fd, &rq, sizeof(rq)) < (ssize_t)sizeof(rq))
   ERROR;
  if(read(fd, &rp, sizeof(rp)) < (ssize_t)sizeof(rp))
   ERROR;

  /* status is zero here */
  if(!rp.status){
   x11_rp_error_t* e_rp = (x11_rp_error_t*)&rp;

This request fails with the "wrong opcode" error code. I've spend few days investigating the failure, still can't find a cuse of it.

0

There are 0 best solutions below