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()


Richard Pennington wrote:
> jerzy dyrda wrote:
>> Hello all,
>>
>> I have problem with obtaining sockaddr from recvfrom() - function
>> doesn't return any socket address.
>>
>> I do it in such way :
>>
>> Socket is opened for UDP datagram :
>>  fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>>
>> and bind to some port:
>>
>> addr.sin_family = AF_INET;
>> addr.sin_addr.s_addr = htonl(INADDR_ANY);
>> addr.sin_port = htons(RMCP_UDP_PORT);
>> rc = bind (fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
>>
>> and next I'm waiting for a packet:
>> ret = recvfrom(fd, &rmcp_packet_raw, IPMI_BUF_SIZE, 0,
>>                     &remote_addr, &remote_addr_len);
>> Received packet is correct according to length and contents but as I
>> mention in subject without a socket addres. It's confusing for me
>> because the same code works as Linux application.
>> I'm using FreeBsd stack from version 2_0 of eCos
>>
>> Any suggestion is appreciated.
>>
>> Best regards,
>> jerzy
>>
> 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.


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

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