473,396 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Find out if a string is an IP address or host name

Xx r3negade
I'm making a C++ wrapper for the standard C BSD sockets. In my object's "connect" function, I have a "host string" that can be either a host name or an ip address. Is there any C function, or any method, of determining if the string follows IP addressing format. I do *not* want to use any regex library or anything of that sort, as it adds unneeded bloat and complication. However, string parsing is nasty in C / C++ and I'd rather not write my own implementation either.
Jul 25 '08 #1
2 2996
gpraghuram
1,275 Expert 1GB
You can parse the string to see if it contains only numbers and . then it is an IP address.
else it should be a host name.
What i am suggesting is a very crude way of doing this

Raghu
Jul 25 '08 #2
sicarie
4,677 Expert Mod 4TB
Did you look at what libraries have been created to take and manipulate IP addresses?
Jul 25 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: none | last post by:
I want to determine the outside (non local, a.k.a. 127.0.0.x) ip addresses of my host. It seems that the socket module provides me with some nifty tools for that but I cannot get it to work...
24
by: Wim Roffal | last post by:
Is there a possibility to do a string replace in javascript without regular experessions. It feels like using a hammer to crash an egg. Wim
2
by: amirmira | last post by:
Hi, I have an application where I monitor the status of a machine using it's IP address. I would like to log an error when the machine goes down - but I want to add the name of the machine along...
1
by: ruca | last post by:
hi, Can Anyone tell me or indicate some sites to get information, what's the differences between calling my Web Application with an Ip Address or the Server Name??? Example: Ip Address...
5
by: Olly | last post by:
Hello Group: I'd be grateful to anyone who can help me with Javascript form. :-) I want users to submit a web form, but to stop the form submission if any of my text fields contain specific...
5
by: Hooyoo | last post by:
Hi, here, How to get local machine name and IP address? Thanks.
1
by: danknauf | last post by:
I have a webserver which is behaving strangely. The server is a fresh copy of Windows 2003 running IIS with default options + Active Server Pages installed. The server is connected to a Linksys...
2
by: madhumathikv | last post by:
Hi, How to find the ip of a host while we know its name. for ex:- gw=idc-mgr //name of the host. how to get its ip address... thanks
2
by: mlb5000 | last post by:
I seem to be having issues validating an XML document using my schema. Both are below: The Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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...
0
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,...

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.