LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 08-02-2010, 04:19 AM   #1
Rahul_Y
LQ Newbie
 
Registered: Apr 2009
Posts: 4

Rep: Reputation: 0
Can I use hostname (a URL) in Socket program?


Hi,

I don't have the IP address & Port of the server but I know the hostname (URL) to establish a connection.

How can I use it to get connected to the particular host?

Regards,
Rahul.

Last edited by Rahul_Y; 08-02-2010 at 04:50 AM.
 
Old 08-02-2010, 04:52 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Rahul_Y View Post
Hi,

I don't have the IP address & Port of the server but I know the hostname (URL) to establish a connection.

How can I use it to get connected to the particular host?

Regards,
Rahul.
I think

man 3 getaddrinfo

is a good start. See also http://c-ares.haxx.se/ .
 
Old 08-02-2010, 05:49 AM   #3
Rahul_Y
LQ Newbie
 
Registered: Apr 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Hi Sergei Steshenko,

Thanks for the reply.

Could you please give an example for getaddrinfo.

I am trying from my side too.

Regards,
Rahul
 
Old 08-02-2010, 06:12 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Rahul_Y View Post
Hi Sergei Steshenko,

Thanks for the reply.

Could you please give an example for getaddrinfo.

I am trying from my side too.

Regards,
Rahul
The manpage has example code, doesn't it ?
 
Old 08-02-2010, 06:24 AM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
FWIW, 'c-ares' is used in 'aria2': http://aria2.sourceforge.net/ - the latter uses URLs, so there is an example inside 'aria2'.
 
  


Reply



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
URL parsing program in perl ludeKing Programming 3 09-30-2010 03:58 PM
Socket program doubt Gwapala Linux - Networking 1 07-22-2010 02:37 PM
Hide hostname in url nahom2112 Linux - Newbie 4 12-27-2009 05:48 PM
Question about changing hostname, it does not change the url mrotsliah Linux - Server 3 08-27-2009 12:26 PM
Execute lynx in a c program and make it go to a certain URL tinieprotonjam Programming 2 12-10-2006 11:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:57 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration