PyArg_ParseTuple for structs or binary data

Alvin Delagon adelagon at gmail.com
Thu Apr 10 03:17:59 EDT 2008


Hello Gabriel,

I just recently discovered that struct.pack does return a string. Everything
works fine now. Thanks for the heads up!

static PyObject *
sendMessage(PyObject *self, PyObject *args)
{
  char *msg = "";
  int len;
  if (!PyArg_ParseTuple(args, "s#", &msg, &len))
    return NULL;
  ret = sctp_sendmsg(connSock, msg, len, 0, 0, 0x03000000, 0, 0x01, 0, 0);
  return Py_BuildValue("l", ret);
}

---
Alvin Delagon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080410/9a9edb21/attachment-0001.html>


More information about the Python-list mailing list