473,785 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

linux tcp/ip: How to reverse resolve a hostname from an ip address?

Hi all!

I'm attempting at writing a networked program. It is going to be a threaded
irc server in c++ using almost nothing but oop code.
And it needs to know the full hostname of the users that connect to it. I
already get some info from this code:

workersock = accept(masterso ck, &sockaddr, &addrlen);
printf("Receive d a Client Connection from: %s port: %d fd: %d\n",
inet_ntoa(socka ddr.sin_addr), ntohs(sockaddr. sin_port), workersock);

But it also needs to get the hostname resolved.. Something like 127.0.0.1
would resolve to localhost.local domain but for every possible ip (if there
is a dns that knows the hostname ofcourse)
I don't mind if the command or routine would take some time, becouse it is
going to work from within a thread either way.. (It would have to be thread
safe too then i guess)
I've searched google for it and looked through some groups, but can't seem
to find it.

Any help is more than welcome. Tnx in advance..

Tim.
Jul 19 '05 #1
2 9830
>> irc server in c++ using almost nothing but oop code.
printf("Receive d a Client Connection from: %s port: %d fd: %d\n",
inet_ntoa(socka ddr.sin_addr), ntohs(sockaddr. sin_port), workersock);


Hmm???

Jonathan

Jul 19 '05 #2

"Jonathan Mcdougall" <DE************ ******@yahoo.ca > wrote in message
news:er******** *************** *********@4ax.c om...
irc server in c++ using almost nothing but oop code. printf("Receive d a Client Connection from: %s port: %d fd: %d\n",
inet_ntoa(socka ddr.sin_addr), ntohs(sockaddr. sin_port), workersock);


Hmm???

Jonathan


i said almost.. ;D
I kinda like printf much better than cout.. If that was what you meant.. :)

Tim.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
25841
by: Sheela | last post by:
I am trying to access the tables of a remote database(db2) from db1 database. I am getting the following error: ORA-12154: TNS:could not resolve service name I tried tnsping the db2 service_name and it is working. I created a dblink like this at db1. CREATE DATABASE LINK db2.oracle.com
2
6140
by: Rob Levine | last post by:
Hi All, This is a cut down version of a post from earlier entitled "Name resolution in .Net". Apologies, for the repeat, but I think the first post was too verbose (it came from a blog article of mine) and I think a shorter post here is probably more appropriate. I am seeing some incorrect behaviour on System.Net.Dns.Resolve( hostname ) It would appear that this does more than just a DNS lookup (which is what it says in the...
1
1809
by: brcimo | last post by:
Does anyone know if there is a way to get all the IP's associated to a host name from a DNS server? I'm thinking along the lines of Dns.Resolve Method. But as stated in the remarks: . The Resolve method queries a DNS server for the IP address associated with a host name or IP address. When hostName is a DNS-style host name associated with multiple IP addresses, only the first IP address that resolves to that host name is returned.
0
1002
by: Mike Eaton | last post by:
Hi all, I'm getting an error when I attempt to run the Dns.Resolve(hostName) method: No more results can be returned by WSALookupServiceNext I am able to ping the hostname I'm attempting to resolve from the command prompt, so it seems like my OS can resolve the hostname properly.
5
5093
by: smatta | last post by:
I have just installed MySql version 5.0-18 on Red Hat Fedora Core 4. It is running but I cant connect to it using MySql Query Browser running on my pc. >From my pc, I can telnet to the sql server / port. I get back a garbled message: 5.0.18-standard§}WxyuadT,☻V6F?J5i1YMT= Should this be garbled ? or is there a problem ?
1
2255
by: kvnsdr | last post by:
I can type an IP address and receive Internet domain name and my workstation name however no other IPs of computers on our internal network will resolve to a thier machine name only to the same IP that is entered. What's up Microsoft???? I can say that before we switched over .NET 1.1 to 2.0 the Dns.Resolve(entry); would find a name for any IP, LAN or WAN. Q. Any ideas??????????
2
24283
by: dariophoenix | last post by:
Hi, I am trying to encapsulate Linux sockets and POSIX threads in C++ classes (I work in Knoppix, using KDevelop). Since sockets and threads are new to me, I searched for example code and found the following: #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <netdb.h>
8
5027
by: schaf | last post by:
Hi NG! I have a problem in my remote application. After calling a remote function the calculation will be done by the service. The calculation result will be sent to the caller (client) via remote event. The following behavior can be observed: 1.) Right after the start of the server the first response via remote event will take a long time.
5
14552
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I am trying to get the DNS name of an arbitrary IP address on the network. If I use GetHostEntry as the documentation suggests I only get the name of the machine I am running the code on. All other IP’s returns the IP in the HostName property of the IPHostEntry object returned by GetHostEntry. If I use Dns.GetHostByAddress or Dns.Resolve I get the name, but these are marked as obsolete. What is the correct way to get this...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.