Skip to contentSkip to conversation

Very Urgent !! (2'nd Post) Not able to recieve messages using sock_recvmsg()

DISCUSSION VIJAYABHASKAR 1 participant 1 message Jan 12, 2004 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

HI Krishna,
It is not printing the length,stucking in that statement it self. I am sending about 10 characters from the client
client using the following code to send:
char buf[10]="123456789";

        iov.iov_base=(void *)buf;
        iov.iov_len=(size_t)10;

        msg.msg_name=NULL;
        msg.msg_namelen=0; //sizeof(server);
        msg.msg_iov=&iov;
        msg.msg_iovlen=1;
        msg.msg_control=NULL;
        msg.msg_controllen=0;
        msg.msg_flags = 0;

for (i=0;i<NUM_PACKAGE;i++)

                {
                 //strcpy(buf,"1");

                 oldfs = get_fs(); set_fs(KERNEL_DS);
                 error = sock_sendmsg(Socket[0], &msg,10);

                /* len = sock_recvmsg(Socket[0], &msg, (size_t)buf, 0);
                 set_fs(oldfs);

                 if (len<0)
                        printk(KERN_ALERT "ERRO receive ########\n");*/

                 if (error<0)
                        printk(KERN_ALERT "Erro send msg ERRO = %d

buf=%s\n",error,buf);
}

Server side using the following code:

iov.iov_base = (void *)buf;
        iov.iov_len = (size_t)10;

        msg.msg_name = NULL;
        msg.msg_namelen = 0;
        msg.msg_iov = &iov;
        msg.msg_iovlen = 1;
        msg.msg_control = NULL;
        msg.msg_controllen = 0;
        msg.msg_flags = 0;

        len = 0;
for (i=0;i<1;i++)
                {
                 oldfs = get_fs(); set_fs(KERNEL_DS);
                 printk(KERN_ALERT " before recieving message \n");
                 len = sock_recvmsg(newsock, &msg,10, 0);
                 printk( KERN_ALERT " Recieved message length is %d
\n",len);
                 printk( KERN_ALERT "recieved message is %s",buf);

}

Am i doing wrong??
Please clarify...
Thanks
Bhaskar
-----Original Message-----
From: Krishnakumar. R [mailto:[email protected]]
Sent: Monday, January 12, 2004 5:36 PM
To: [email protected]
Subject: Re: Very Urgent !! (2'nd Post) Not able to recieve messages using sock_recvmsg()

Hello Bhaskar,

What is the return value you are getting.
ie. Did you try printing the return value
and see what is being printed.

Some thing like the following.

Quoted 1 line

len = sock_recvmsg(newsock, &msg, (size_t)buf, 0)

printk("Return value = %d \n", len);

Quoted 1 line

printk( KERN_ALERT "recieved message is %s",buf)

Hope that helps,
Regards,
KK.

PS: Are you an alumni of GEC TCR ?