LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-12-2012, 12:35 AM   #1
batman4
Member
 
Registered: Jul 2012
Posts: 47

Rep: Reputation: Disabled
find ip address in c programming of server in client server


please help
i have to print ip address from sockaddr of server thru c programming :
 
Old 09-12-2012, 03:36 AM   #2
Celyr
Member
 
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 314

Rep: Reputation: 77
Code:
man inet_ntoa
 
Old 09-12-2012, 04:59 AM   #3
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,523

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by Celyr View Post
Code:
man inet_ntoa
That function has been deprecated; one should use inet_ntop() to get support for IPv6 addresses as well.
 
Old 09-12-2012, 05:02 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,819

Rep: Reputation: 505Reputation: 505Reputation: 505Reputation: 505Reputation: 505Reputation: 505
And before inet_ntoa: getpeername.
 
Old 09-12-2012, 05:10 AM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,523

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by NevemTeve View Post
And before inet_ntoa: getpeername.
getpeername() is useful if all one has is the socket descriptor. However, if one has a "pre-filled" sockaddr structure that is returned by accept() (when using TCP) or by recvfrom() (when using UDP) then it should be sufficient to go straight to using inet_ntop().
 
Old 09-12-2012, 05:21 AM   #6
Celyr
Member
 
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 314

Rep: Reputation: 77
Quote:
Originally Posted by dwhitney67 View Post
That function has been deprecated; one should use inet_ntop() to get support for IPv6 addresses as well.
Oh, nice to know, sorry for the mistake
 
  


Reply

Tags
clientserver


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
client -server c programming batman4 Programming 4 09-13-2012 09:36 AM
Can't find address for server XXX.com.jo: Server failed skuli434 Linux - Newbie 2 02-23-2012 03:05 AM
client's IP address in server? hegdeshashi Linux - Networking 2 01-05-2006 03:15 AM
How to get IP address of client from server.c program nazsarwat Programming 1 04-22-2005 03:57 PM
how to get client ip address at udp server cranium2004 Programming 2 03-21-2005 11:35 PM


All times are GMT -5. The time now is 11:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration