This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: is this a bug? (sendto socket call)


Nick,

Thanks.  I thought I had tried it the way you suggested, but I had actually only changed the address field to zero instead of passing in a zero for the 'to' pointer.  Now I can do it right in Linux as well.

Rich

-----Original Message-----
From: nickg@xl5.calivar.com [mailto:nickg@xl5.calivar.com]On Behalf Of
Nick Garnett
Sent: Tuesday, July 20, 2004 10:51 AM
To: von Lehe, Richard H
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] is this a bug? (sendto socket call)


Richard.von.Lehe@gd-ais.com writes:

> Hi All,
> 
> When I debugged deep into the various calls underneath 'sendto', I
> came across this section of code.  The call stack is something like
> this (not exact):
> 
> sendto -> sosend -> udp_send -> udp_output
> 
> In udp_output (udp_usrreq.c):
> ----------------- code -----------------------
>     	if (addr) {
>     		sin = (struct sockaddr_in *)addr;
>     		laddr = inp->inp_laddr;
>     		if (inp->inp_faddr.s_addr != INADDR_ANY) {         // <-------------------- ??
>     			error = EISCONN;
>     			goto release;
>     		}
> -------------------- end code -----------------------
> 
> The string inp_faddr is #defined to be inp_dependfaddr.inp46_foreign.ia46_addr4.
> 
> The structure for 'inp' is at the bottom of this email.  Anyway, in
> my debugger I see that inp_dependfaddr.inp46_foreign.ia46_addr4 is
> my desired remote address and
> inp_dependladdr.inp46_foreign.ia46_addr4 is one of my local
> addresses.  Of course my remote address is not 0.0.0.0 (INADDR_ANY)
> and I get the 'is already connected' (EISCONN) error.  Does this
> make sense to anyone else?  It doesn't to me.  I can include any
> other information if this isn't enough.  I am using 'sendto' in a
> way that seems to work when I compile and run under Linux instead of
> eCos.
>

If you have called connect() to connect the socket to a specific
remote address then you cannot supply a destination address to
sendto(). Either use send() or set to and tolen to zero in the
sendto() call.

Just because Linux lets it through doesn't mean it is right. In a
contest beteween Linux and BSD for the correct semantics of the socket
calls, I know which one I would believe. :-)

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]