This is the mail archive of the ecos-discuss@sourceware.org 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: Problem with obtaining sockaddr from recvfrom()


Hello all,

> > Not sure if this is your problem, but I have
> > #if defined(__ECOS)
> >     addr.sin_len = sizeof(addr);
> > #endif
> >
> > in code that I use.
>
> This is quite possibly the source of the problem.
>
> The standard test program:
>   .../net/common/current/tests/udp_lo_test.c
> does a recvfrom() and successfully prints the source address,
> so we're pretty sure that the system [calls] work properly.
>
> Try looking at the test/example programs.
Thanks a lot for hints and suggestions.
The case was missing of initialization addr_len with length of structure  
before calling recvfrom() i.e.
/* remote_addr_len == 0 */
ret = recvfrom(fd, &rmcp_packet_raw, IPMI_BUF_SIZE, 0,
                                       &remote_addr, &remote_addr_len);
and as I suppose recvfrom() treat remote_addr as structure with zero length 
buffer :(
 
It's done in the standard test program udp_lo_test.c

    c_len = sizeof(c_addr);
   ^^^^^^^^^^^^^^
	
    if ((len = recvfrom(s_source, data_buf, sizeof(data_buf),0,
                        (struct sockaddr *)&c_addr,&c_len)) < 0  ) {
        CYG_TEST_FAIL_FINISH("I/O error");
    }


Best regards,
jerzy

-- 
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]