title: Finding IP address and port number using socket api?
body: <p>I am working on a code where I have need to find the sender's IP address,sender's port no and application layer packet sent by it. </p>
  
  <p>I did it using Raw Sockets (SOCK_RAW), it runs fine and did the job for me but its too much clumsy. </p>
  
  <p><strong>Question:</strong> I can use SOCK_STREAM and get the application layer packet directly and that's really clean and simple method than using Raw socket but this way I won't be able to find the IP address and port number of the client. Is there any function to which I pass the socket descriptor and it tells me the IP address and port number of the other end. I read a few man pages but I could not find any.</p>
  
  <p>I am using linux socket api in C language.</p>
  
  <p>Thanks in advance. :)</p>