hi, actually i'm using a socket of type SOCK_STREAM. i also set the MSG_WAITALL flag within the sock_recvmsg but this causes that socket hangs up. the return code in this case is -512. i cant find any data about it... any hints????? regards benny Rithin Kumar Shetty sagte: > What type of socket are you using ? I mean there are several types of > them : > SOCK_STREAM, SOCK_DGRAM, SOCK_RAW etc. Which one did you use ? > Based on the type of the socket functions like tcp_recvmsg, udp_recvmsg > etc are called > from sock_recvmsg when it calls sock->ops->recvmsg(). So you may want > to look at those > functions to know what is happening. > > Hope this Helps, > Rithin. > > > TI8 Benjamin Kohler wrote: > >>hi, >> >>i just wrote a kernel module which sends some data to a server. after >> the server has received the data it sends back some data to the kernel >> module. sending data from the module to the server works! but i cant >> get the response sent by the server. >>for receiving data within my kernel module i use the sock_recvmsg >> function. the return value is always 0. does anybody know how i have >> exactly to use this function so that i can receive any data within my >> kernel module >> >>here is my Send_Msg function within my Kernel Module: >> >> >>int Send_Msg(const char *buffer) >>{ >> struct msghdr send_msg; >> struct msghdr recv_msg; >> struct iovec iov; >> struct timeval now1; >> mm_segment_t oldfs; >> int error,i,len,lat; >> char recv_buf[1024]; >> int j = 0; >> >> >> iov.iov_base=(void *)buffer; >> iov.iov_len=strlen(buffer); >> printk("<1>Size of Buffer in Send_Msg: %d\n", sizeof(buffer)); >> >> send_msg.msg_name=NULL; >> send_msg.msg_namelen=0; //sizeof(server); >> send_msg.msg_iov=&iov; >> send_msg.msg_iovlen=1; >> send_msg.msg_control=NULL; >> send_msg.msg_controllen=0; >> send_msg.msg_flags = 0; >> >> do_gettimeofday(&now1); >> >> oldfs = get_fs(); set_fs(KERNEL_DS); >> error = sock_sendmsg(Socket[0], &send_msg, (size_t)buffer); >> set_fs(oldfs); >> >> iov.iov_base=(void *)recv_buf; >> iov.iov_len=sizeof(recv_buf); >> >> recv_msg.msg_name=NULL; >> recv_msg.msg_namelen=0; //sizeof(server); >> recv_msg.msg_iov=&iov; >> recv_msg.msg_iovlen=1; >> recv_msg.msg_control=NULL; >> recv_msg.msg_controllen=0; >> recv_msg.msg_flags = 0; >> >> udelay(1000); >> >> >> oldfs = get_fs(); set_fs(KERNEL_DS); >> len = sock_recvmsg(Socket[0], &recv_msg, (size_t)recv_buf, >> MSG_WAITALL); set_fs(oldfs); >> >> if (len<0) >> printk(KERN_ALERT "ERRO receive ########\n"); >> >> if (error<0) >> printk(KERN_ALERT "Erro send msg ERRO = %d >> buffer=%s\n",error,buffer); >> >> printk("<1>recieved bytes: %d\n", len); >> >> >> sock_release(Socket[0]); >> return 0; >>} >> >> >>the sock_sendmsg works fine, but the sock_recvmsg() always seems to >> fail!!! Any help out there??? >> >> >>greetings >>benny >> >> -- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/