473,513 Members | 4,116 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(mastersock, &sockaddr, &addrlen);
printf("Received a Client Connection from: %s port: %d fd: %d\n",
inet_ntoa(sockaddr.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.localdomain 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 9810
>> irc server in c++ using almost nothing but oop code.
printf("Received a Client Connection from: %s port: %d fd: %d\n",
inet_ntoa(sockaddr.sin_addr), ntohs(sockaddr.sin_port), workersock);


Hmm???

Jonathan

Jul 19 '05 #2

"Jonathan Mcdougall" <DE******************@yahoo.ca> wrote in message
news:er********************************@4ax.com...
irc server in c++ using almost nothing but oop code. printf("Received a Client Connection from: %s port: %d fd: %d\n",
inet_ntoa(sockaddr.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
25817
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
6127
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 )...
1
1801
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...
0
988
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
5073
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
2241
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...
2
24267
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
5017
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...
5
14476
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...
0
7270
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...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7125
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...
0
7543
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...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4757
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...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
470
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...

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.