473,378 Members | 1,355 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,378 software developers and data experts.

How to capture last octect of an IP address in C++?

I want to parse the IP address data to capture the last octect. Are
there any socket calls which can be directly used?

Aug 23 '05 #1
3 1781
so************@gmail.com wrote:
I want to parse the IP address data to capture the last octect. Are
there any socket calls which can be directly used?


C++ doesn't deal with sockets. You will have to refer to the newsgroup
for the operating system you are using.

Aug 23 '05 #2
so************@gmail.com wrote:
I want to parse the IP address data to capture the last octect. Are
there any socket calls which can be directly used?


Sockets, IP address, are off-topic here. You might want to post this
to a newsgroup for your platform, where network programming questions
usually belong.

If you just want to parse a string in the form "X.X.X.X" where 'X' is
an integer number, then then simplest way is to find the last '.' and
extract the number. Use 'strrchr' and 'strtol'.

V
Aug 23 '05 #3

so************@gmail.com wrote:
I want to parse the IP address data to capture the last octect. Are
there any socket calls which can be directly used?


unsigned char last_ip4_octet(char const* addr)
{
unsigned char t[4];
if(4 != sscanf(addr, "%hhu.%hhu.%hhu.%hhu", t + 0, t + 1, t + 2, t
+ 3))
throw std::invalid_argument("bad ip address format");
return t[3];
}

Aug 23 '05 #4

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

Similar topics

2
by: Hugh McLaughlin | last post by:
Hello everyone and thanks for your help in advance. I am working on an application to track visitors to my website. However, I am confused as to what data to capture for the session, specifically...
8
by: George Hester | last post by:
When the address bar is highligted? That is nothing on the page is selected. The address bar is selected. Capture keydown or keypress? Any ideas using javascript? Thanks. -- George Hester...
0
by: Mark Barinstein | last post by:
Hello. W2K, db2 v7, FP10a. Before now our replication worked properly. But some days ago capture suddenly stopped loggin and filling cd tables without any messages. The last message was like...
3
by: bloc | last post by:
I am programming an interactive CV using xml, xslt and java script. The page consists of a header which contains links to various 'sections' on the xml cv, a left and right menu, and a central...
0
by: j101 | last post by:
I am attempting to set up Q Capture on RH Linux (x86_64) using DB2 9 fp2, but there seems to be a general problem loading a specify MQ shared library "/opt/mqm/lib/libmqm_r.so". I have MQ v6...
1
by: sangith | last post by:
Hi, I tried the packet capture module program. I did a file transfer using ftp from this host to another server. But when I ran the program, it was just hanging off and it did not print the...
6
by: k.vanderstarren | last post by:
Hi Everyone, Do any of you gurus out there have any suggestions regarding capturing audio/video from a video capture card in C#. Although I've written other programs, I've never worked with...
11
osward
by: osward | last post by:
Hello everyone, My site needs to support 3 different languages that runs under phpnuke 8.0, phpnuke provides language interface select function that allows switching from different interface,...
1
by: ZnoogForum | last post by:
I have searched the internet far and wide and have still failed to locate any programs/scripts that can capture an IP Address along with who the internet provider is of that IP Address. Here is my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.