Re: UDP sendto/recvfrom error
Ben Bridgwater (bennyb@ntplx.net)Tue, 13 Jul 1999 17:23:47 -0400
- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Bryn Paul Arnold Jones: "Re: Debugging with NMI"
- Previous message: Mark H. Wood: "Re: [Call For Wartectomy] CRLF conversion out of kernel"
- Maybe in reply to: Tracy Xiaodi Lu: "UDP sendto/recvfrom error"
Tracy Xiaodi Lu wrote:
> I hope someone can help to tell me why I met this error.
> ------------------OK---------------
> int client_len;
> int n=0;
> while(1)
> {
> if (n=recvfrom(sockfd,buffer,size,0,pclient_addr,&client_len))<=0)
> printf("error");
> sendto(.....)
> }
> ------------------ recvfrom error-----------
> int n=0;
> int client_len;
> while(1)
> {
> if (n=recvfrom(sockfd,buffer,size,0,pclient_addr,&client_len))<=0)
> printf("error");
> sendto(.....)
> }
> ------------------
>
> I found if I declare the int client_len right before the while loop, the
> recvfrom fucntion will return the "Invalid Argument" (22) error. But it
> works fine if I declare one of more variable after client_len.
>
>
client_len is used to pass in the size of the socket address buffer, as
well as return the actual length - you need to assign it before the
call.
Ben
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
No comments:
Post a Comment