Usage of BIF port_control/3?

Scott Lystig Fritchie scott@REDACTED
Mon Feb 28 09:23:58 CET 2000

>>>>> "ph" == Peter H|gfeldt <peter@REDACTED> writes:

ph> The port_control/3 BIF only works for drivers that have
ph> implemented the control() function (see erl_driver.h for the ANSI
ph> prototype).

Silly me.  I should've looked at that.

I now understand why I wasn't getting the results I was expecting: the
control function is only partially implemented:

static int inet_ctl(inet_descriptor* desc, int cmd, char* buf, int len, 
                    char** res_buf, int res_size)
    switch (cmd) {
    case INET_REQ_GETSTAT: {  /* only option avail now */
          char* dst;
          int dstlen = len*5 + 1;  /* resulting length */

          if (dstlen > INET_MAX_BUFFER) /* sanity check */
              return 0;
          if (dstlen > res_size) {
              if ((dst = (char*) ALLOC(dstlen)) == NULL)
                  return 0;
              *res_buf = dst;  /* call will free this buffer */
              dst = *res_buf;  /* ok we fit in buffer given */
          return inet_fill_stat(desc, buf, len, dst);
        return 0;

Foo on me for assuming it would be fully implemented.  :-)  Many thanks!


More information about the erlang-questions mailing list