N
nishant
I've a structure:
struct msghdr
{
//some goes here
struct iovec *msg_iov;
//some more ---
}
struct msghdr msg;
The body of struct iovec looks like this:
struct iovec
{
void *iov_base; // to point to a (char *) buffer
int iov_len;
}
I declare a struct iovec array:
struct iovec iov[10];
Then fill it with values after proper memory allocation:
for i: 0 to 9
strcpy(iov.iov_base, buf);
iov.iov_len = length;
Then i make *msg_iov to point to this array:
msg.msg_iov = iov;
my question is when i try to access iov_base by:
msg.msg_iov.iov_base
it works only for i=0, for the rest it shows NULL.
Now the interesting part, when i pass the
address of 'msg' to a display function (display(struct msghdr *msg))
then in that function i'm able to access the buffers without any problem
using,
msg->msg_iov.iov_base
Isn't this weird?
Why will a 'access method' make any difference
Any suggestion/clarifications are welcome.
struct msghdr
{
//some goes here
struct iovec *msg_iov;
//some more ---
}
struct msghdr msg;
The body of struct iovec looks like this:
struct iovec
{
void *iov_base; // to point to a (char *) buffer
int iov_len;
}
I declare a struct iovec array:
struct iovec iov[10];
Then fill it with values after proper memory allocation:
for i: 0 to 9
strcpy(iov.iov_base, buf);
iov.iov_len = length;
Then i make *msg_iov to point to this array:
msg.msg_iov = iov;
my question is when i try to access iov_base by:
msg.msg_iov.iov_base
it works only for i=0, for the rest it shows NULL.
Now the interesting part, when i pass the
address of 'msg' to a display function (display(struct msghdr *msg))
then in that function i'm able to access the buffers without any problem
using,
msg->msg_iov.iov_base
Isn't this weird?
Why will a 'access method' make any difference
Any suggestion/clarifications are welcome.