[uClinux-dev] sendto does not work, send and sendmsg do
Stanislav Meduna
stano at meduna.org
Tue Oct 9 06:23:03 EDT 2007
Hi,
are there known problems with the (UDP) sendto method and/or
with ABI accessing syscalls with more arguments?
The following gives back EINVAL:
int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in sock_addr;
memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
sock_addr.sin_port = htons(61444);
sock_addr.sin_addr.s_addr = inet_addr("192.168.130.27");
r = sendto(sock, (const char *) &i, 4, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
Scattering all the data to msghdr/iovec and replacing sendto with
sendmsg works:
struct msghdr msg;
struct iovec iov;
iov.iov_base = &i;
iov.iov_len = 4;
msg.msg_name = (struct sockaddr *)&sock_addr;
msg.msg_namelen = sizeof(sock_addr);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = 0;
msg.msg_controllen = 0;
msg.msg_flags = 0;
r = sendmsg(sock, &msg, 0);
The connect() and subsequent send() works ok:
connect(sock,(struct sockaddr *)&sock_addr, sizeof(sock_addr));
r = send(sock, (const char *) &i, 4, 0);
I am using uClibc from uClinux 20070130 +
uClinux-dist-20070130-20070823.patch.gz and a gcc-4.2.1/binutils-2.17
based toolchain on an ARM7TDMI device. However, the device I am runnig
this on uses an older version of uClinux and the kernel (2.6.14)
was compiled with gcc 3.4.3.
Any ideas?
Thanks
--
Stano
More information about the uClinux-dev
mailing list