title: Two way UDP client and server?
body: <p>I'm trying to implement a basic file transfer protocol, using UDP. 
  I'm using Beej's Guide as a reference, and much of the code I will post is from there. </p>
  
  <p>My program so far has the 'talker' send the name of the file it wants to the 'receiver'.  </p>
  
  <p>From there, the reciever checks if the file exists, and if it does, it figures out the size of the file. </p>
  
  <p>Now here is where I run into problems. I need the receiver to send the size of the file to the talker. You can see in my code (links below) how I implemented it. However, the talker just hangs, like it's still waiting for something to be sent. </p>
  
  <p>This makes me think the reciever needs some additional code to allow it to communicate back to the talker, and not just recieve data from it (I'm used to TCP, so excuse my lack of knowledge). </p>
  
  <p>Could someone tell me what code I am missing, or if I am using the functions wrong? It's difficult to follow Beej's guide, and he does not provide an example of a two-way communication. </p>
  
  <p>Thanks, and let me know if you need any more info. </p>
  
  <hr>
  
  <p>Listener: <a href="http://pastebin.com/UL1xjDnP" rel="nofollow">http://pastebin.com/UL1xjDnP</a></p>
  
  <p>Talker: <a href="http://pastebin.com/B2zrXPgZ" rel="nofollow">http://pastebin.com/B2zrXPgZ</a></p>
  
  <hr>
  
  <p>EDIT: Solved!
  Thanks to cnicutar, </p>
  
  <p>I was addressing the server in this code, when i should have addressed the client</p>
  
  <p><code>if ((numbytes = sendto(sockfd,buffer,strlen(buffer), 0,
      p-&gt;ai_addr, p-&gt;ai_addrlen)) == -1)</code></p>
  
  <p>which should be changed to </p>
  
  <p><code>if ((numbytes = sendto(sockfd,buffer,strlen(buffer), 0,
      (struct sockaddr *)&amp;their_addr, &amp;addr_len)) == -1)</code></p>