how to get ip address from sock structure in c ?

Posted by REALFREE on Stack Overflow See other posts from Stack Overflow or by REALFREE
Published on 2010-06-17T10:48:37Z Indexed on 2010/06/17 10:53 UTC
Read the original article Hit count: 483

Filed under:
|
|
|

I'm writing simple server/client and trying to get client ip address and save it on server side to decide which client should get into critical section. I googled it several times but couldn't find proper way to get ip address from sock structure.

I believe this is a way to get ip from sock struct after server accept request from client more specifically in c after server execute

csock = accept(ssock, (struct sockaddr *)&client_addr, &clen) 

Thanks

© Stack Overflow or respective owner

Related posts about c

    Related posts about socket