Solved

UDP - recvfrom() call

Posted on 2000-04-04
7
475 Views
Last Modified: 2008-03-17
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 
0
Comment
Question by:Robson
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:munsie
ID: 2685755
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
0
 
LVL 4

Author Comment

by:Robson
ID: 2686743
I've put sources of A and B at http://rainbow.mimuw.edu.pl/~robson/AB.tgz
0
 
LVL 4

Author Comment

by:Robson
ID: 2686751
Edited text of question.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Accepted Solution

by:
munsie earned 300 total points
ID: 2687360
in your get_answer2() routine, you didn't set the length field to be the sizeof(answer).  Actually, you didn't do this in multiple places...

set length before calling recvfrom() will fix your problem.

good luck,
dennis
0
 
LVL 4

Author Comment

by:Robson
ID: 2687763
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!
0
 
LVL 2

Expert Comment

by:munsie
ID: 2687971
glad it helped... sorry about the sci-fi convention, though

dennis
0
 
LVL 4

Author Comment

by:Robson
ID: 2688162
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 :-).  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LDAP server on Linux Redhat 6 2 492
what does getent do 3 46
„dd“ vs „ddrescue“ 28 213
how awk substr works and also how index works in inside substr? 4 77
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now