Link to home
Start Free TrialLog in
Avatar of Robson
RobsonFlag for Poland

asked on

UDP - recvfrom() call

There are two simple programs: A, and B communicating through UDP (socket() called with SOCK_DGRAM). A just bounces all datagrams.
B sends a datagram to A, calls recvfrom and then
examines the sockaddr *from field.

Depedning on:
a) sockaddr_in declaration or allocation
b) recvfrom calling point
c) B's compilation host
I'm getting different results:

Compiled on my machine (RH 6.1):

sockaddr_in  | recvfrom()     | result
-----------------------------
main()          | main()           | A's address
answer0()     | answer0()      | EINVAL
B.c              | answer1()      | 0.0.0.0
malloc()        | answer2()     | EINVAL

Compiled on my university host:

sockaddr_in  | recvfrom()     | result
--------------------------
main()          | main()           | A's address
answer0()     | answer0()      | 0.0.0.0
B.c              | answer1()      | 0.0.0.0
malloc()        | answer2()     | 0.0.0.0

I don't like the idea of putting all my code
in main(), so hope there's someone who has
at least the slightest idea about what's going
on and how to make it work. I'll provide any
additional information, if it is necessary.

Sources of A and B are here: http://rainbow.mimuw.edu.pl/~robson/AB.tgz 
Avatar of munsie
munsie

the code would be very helpful, if you don't mind... i have a few ideas, but I would like to see what A and B are doing.

thanks,
dennis
Avatar of Robson

ASKER

I've put sources of A and B at http://rainbow.mimuw.edu.pl/~robson/AB.tgz
Avatar of Robson

ASKER

Edited text of question.
ASKER CERTIFIED SOLUTION
Avatar of munsie
munsie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robson

ASKER

Thank's a lot, dennis!
This requirement isn't mentioned either in man page, nor in Steven's book (I 've nearly broken its cover in anger). Also in example programs given by my network-programming teacher (he's going to score some, too) initialization isn't made.

Last, but not least:
I MISSED GREAT SCI-FI CONVENTION BECAUSE OF THIS EFFING BUG!
glad it helped... sorry about the sci-fi convention, though

dennis
Avatar of Robson

ASKER

NOTE: I was wrong about Stevens' "Un*x Network Programming" - it explains this problem. I promise to read it carefully and with respect - and no more violence, of course :-).