cs-pub-ro / operating-systems

Teaching resources (OER) for Operating Systems
https://cs-pub-ro.github.io/operating-systems/
Other
7 stars 52 forks source link

Laboratorul 10, exercitiul cu sender-reciever. #46

Open sqeedward opened 10 months ago

sqeedward commented 10 months ago

Pe scheletul de cod cand rezolvam exercitiul, primul mesaj va fi mereu: Received from IP 0.0.0.0 and port 0: "mesajul". Isi revine ulterior dupa primul input. Screenshot 2023-12-19 114415

gabrielmocanu commented 10 months ago

Hi @sqeedward

It seems like there might be an issue with the sender_addr_len variable. In the recvfrom function, you are passing the address of sender_addr_len to store the size of the sender's address. However, it looks like that sender_addr_len variable is not initialized before calling recvfrom. This could lead to unpredictable behavior and might be the reason why you are not getting the correct IP address.

To fix this issue, you should initialize sender_addr_len before using it. Add the following line before the recvfrom function:

sender_addr_len = sizeof(sender_addr);

Can you do this fix, please?

gabrielmocanu commented 10 months ago

I assigned this issue to @Alex-deVis since he is the owner of the code. He might help you. Otherwise, @Alex-deVis , please make sure we have a fix for this problem.

Alex-deVis commented 3 weeks ago

I'll pass this to @andreia-oca since this might be reused as a demo for GitHub operations.