Programming :: How To Make Pinging Function More Efficient

Mar 13, 2010

I am starting a project of my own (and learning C++ at the same time. I got my program to successfully scan a custom netmask, but it is REALLY slow. I want my program to do something similar to nmap -sP xxx.xxx.xxx.xxx-xxx. How to speed it up? Such as pinging more than one IP at a time...

Code:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;
int ip42;
string ip1, ip2, ip3, ip4, ipaddr;
int main() {

cout << endl << "Enter part 1: ";
cin >> ip1;
cout << endl << "Enter part 2: ";
cin >> ip2;
cout << endl << "Enter part 3: ";
cin >> ip3;
cout << endl << "Enter part 4: ";
cin >> ip4;
while(ip42 < 255){
ipaddr = string("ping -c 1 ").append(ip1);
ipaddr = string(ipaddr).append(ip2);
ipaddr = string(ipaddr).append(ip3);
ipaddr = string(ipaddr).append(ip4);
system(ipaddr.c_str());
ip42 = atoi(ip4.c_str());
ip42 += 1;
stringstream output;
output << ip42;
output >> ip4; } }

View 2 Replies


ADVERTISEMENT

Programming :: Experience To Make A Script More Efficient?

Mar 30, 2010

I wrote this script to attach url's to specified 6 digit numbers in a configuration text file. My original goal was to be able to be able to pull the url's and the 6 digit numbers from .csv files. that would allow me to make the script more versatile, not only for this particular project, but also for other projects in regards to the configuration file. This script works, and has served it's purpose, but it is not very pretty, and it's probably not very efficient. What can I do to improve it and possibly make it more versatile. I've thought about functions and arrays, but my skill set is still pretty limited. I'm not looking for someone to write it for me, just to point me in the right direction.

[Code]...

View 7 Replies View Related

Programming :: Efficient Way To Display JPEG Images In Browsers?

May 12, 2010

What is the efficient way to display jpeg images in browsers using c programming. Any links or any sample code.

View 6 Replies View Related

Programming :: Make A Template Char Or Wchar_t Default Function Argument?

Oct 30, 2009

I have a template similar to the following.

Code:

template <charT>
virtual void do_get_date(charT* = "str")
{ ... }

As you can see we have a problem. If we use a wchar_t instead the string wont be formatted right we need to prefix L in front. If we use char16_t we need to prefix a u in front. Is there a was to make the generic without resorting the the std::string class?

View 2 Replies View Related

Programming :: Efficient Access Of Huge Files Or Defrag Ext4?

Sep 30, 2010

I need to figure out how to arrange for the fastest-possible read-access of a large or huge memory-mapped file. I'm writing high-speed real-time object-chasing software for a NASA telescope (on earth). This software must detect images of fast moving objects (across arbitrary fields of fixed stars), estimate what direction and speed the object image is traveling (based on the length and direction of a streak on the detection image), then chase after the object while capturing new 4Kx4K pixel images every 2~5 seconds, quickly matching its speed and trajectory, then continue to track and capture images until the object vanishes (below horizon, into earth shadow, etc).

I have created two star "catalogs". Both contain the same 1+ billion stars (and other objects), but one is a "master catalog" that contains all known information about each object (128 bytes per object == 143GB) while the other is a "nightly build" that only contains the information necessary to perform the real-time process (32 bytes per object == 36GB) with object positions precisely updated for precession and proper-motion each night. Almost always the information in the "nightly build" catalog will be sufficient for the high-speed (real-time) processes.

[Code]...

View 8 Replies View Related

Programming :: How Can A Friend Function Access A Public Function From A Base Class

Nov 16, 2010

Code:
#include <iostream>
using namespace std;

[code]...

View 1 Replies View Related

Programming :: Passing Data From Interrupt Handler Function To Tasklet Function?

May 18, 2010

I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.

View 2 Replies View Related

Programming :: Declaring A Function In A Function - C Programming

May 24, 2010

I want to declare a function in a function, but had no success till now, see the error code below and visit the project at sourceforge

[Code]...

View 14 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Programming :: Surface Fitting Using NR Function Svdfit ( ) In C Programming?

Sep 16, 2010

fit a surface i.e. W(x,y) using svdfit() provided by "Numerical Recipes in C". svdfit() is written for curve fitting and not for surface fitting.But one can use svdfit(), as claimed by authors of NR book, to do surface fitting. On page 680 of NR book, authors have given a hint on how to use svdfit() for fitting a surface. But I have not understood it.This link may be helpful (Chapter 15 th is relevant here.):[URL]This is my problem:

Code:
I have a set of 100 numbers. I want to fit a 2-Dimensional function W(x,y) to these numbers.

[code]....

View 2 Replies View Related

OpenSUSE :: Make Keycode 22 Have The Same Function As Button 1

Dec 19, 2010

I guess I would have to use xmodmap to do this. I already used XEV to find out that the button I need changed was keycode 22. I have a Dell Vostro 1500 and I want the remote control to have a different function.

suse 11.3 / x32 / kde4

View 1 Replies View Related

Server :: Make A C Function Present In The Library To Execute In Php?

Apr 10, 2011

how to make a c function present in the library to execute in php and should be able to pass a any new argument back to the c library from php

View 2 Replies View Related

Debian Configuration :: Make Localmodconfig Failing To Function Properly?

Aug 23, 2010

The announcement of several new make scripts in the 2.6.32 release notes is very exciting.1.8. Easy local kernel configuration.Most people uses the kernel shipped by distros - and that's good. But some people like to compile their own kernels from kernel.org, or maybe they like following the Linux development and want to try it. Configuring your own kernel, however, has become a very difficult and tedious task - there're too many options, and some times userspace software will stop working if you don't enable some key option. You can use a standard distro .config file, but it takes too many time to compile all the options it enables.

To make easier the process of configuration, a new build target has been added: make localmodconfig. It runs "lsmod" to find all the modules loaded on the current running system. It will read all the Makefiles to map which CONFIG enables a module. It will read the Kconfig files to find the dependencies and selects that may be needed to support a CONFIG. Finally, it reads the .config file and removes any module "=m" that is not needed to enable the currently loaded modules. With this tool, you can strip a distro .config of all the unuseful drivers that are not needed in our machine, and it will take much less time to build the kernel. There's an additional "make localyesconfig" target, in case you don't want to use modules and/or initrds.

View 1 Replies View Related

Ubuntu Networking :: How To Make Wireless Shortcut Function Properly

May 10, 2011

i'm using ASUS K40IE laptop, installed Ubuntu 10.10 and online upgraded to 11.04 (natty), and i have a problem about my wifi.This laptop using Fn+F2 to enable/disable wifi (using Windows work properly with driver from asus) and have a Led that trigger on/off.Using ubuntu, that's shortcut it's useless. i press Fn+F2 many times, but that led indicator never turn off. Is there a way to make that shortcut can function properly? Actually, i'm not often using wifi, so i want to make it default disable on start up. Both ubuntu 10.10 or 11.04 can't using this shortcut.

View 1 Replies View Related

General :: Most Efficient Way Of Taking Subset Of Lines

Feb 9, 2010

I have two files. One huge one (200.000+ lines) called 'db' and one big one (15.000+ lines) called 'indices'.What is the quickest way of filtering out the lines in 'db' containing any index (anywhere on the line) from 'indices'.Is there a faster approach in bash, linux?

View 1 Replies View Related

General :: Need Efficient Pdf Book / Documentation For Learning Scripting

Jun 10, 2010

I am very new in linux/aix scripting. I request you all to give me efficient pdf book or documentation for learning scripting.

View 2 Replies View Related

Ubuntu Networking :: Setup The Most Efficient Way To Remotely Administer A System?

Aug 7, 2010

I am trying to setup the most efficient way to remotely administer an ubuntu system. So far I was successful in setting up ssh. I have the server running and made sure it only uses keys to authenticate and changed the default port. I can connect to the ssh-server. This system is behind nat and bots trying to break-in when I forwarded the port. I used the AllowUsers option, which helped in knocking back these rouge connections. I was not comfortable leaving a port open all the time, so I set up logmein Hamachi VPN and closed the ports that were open on NAT.

Now I use Hamachi and am very impressed. I use VNC in VPN. But Vino is slow, I tested x11vnc and it was slightly faster. I also tried to set up freenx but nxsetup file was missing. some one posted that file in the forums and suggested copying to the system but I was not sure if I want to download a script from the forum and use it. So for the time being, I thought I will just concentrate on X11vnc until freenx is fixed.

I would like to create a separate desktop on the server and use it to access remotely. This way we will not have to fight over the cursor (sounds funny but very frustrating). From what I understand x11vnc has this function inbuilt (uses vncserver). I cannot get it to work! when using ssh, at the remote machine's command prompt, if I type "evince xyz.pdf", it does not launch the "xyz.pdf". what am I doing wrong? When using VNC, how can I change between different users on the remote machines? Right now I can only use VNC in one account that I first setup. When I try to change to another user, vnc client goes blank. How can I get as much control of the remote system as possible? Right now I need someone to switch on the remote system and login to their account before I can VNC. Can I use ekiga inside VPN, I use skype right now and it's sometimes terrible with dropouts. I looked around and someone suggested using ekiga as it works very well over lan. How do set up ekiga so that I have a direct connection with the remote system? Is there any client that just takes the IP address and creates a connection? Mumble seems to be the popular choice, it's most suited to LANparties, I just need a connection between two systems. I am trying to set this up to help users with hardly any computer knowledge to use the system without any issues.

View 7 Replies View Related

Red Hat / Fedora :: Pinging Between Two Ip?

Jul 20, 2010

I have three linux pc. assume server-A, server-B and server-C. server-A is connected with server-B trough eth0 (ip:192.168.1.5) and server-B side ip: (eth0)192.168.1.1. Server-B is connected with server-C through eth1 (ip: 10.10.10.1) and server-C side ip (eth0) : 10.10.1.4.

I want to ping between server-A and server-C. what can i do. if it is possible by iptables what is command.

View 1 Replies View Related

Programming :: Calling An Asm Function From C?

Jun 4, 2010

I have a question about calling an asm function from C....It doesn't work unless I create an asm variable to hold the value of the function in....Why?Here's the code that doesn't work...

asmfile.s - version one Code: .section .data
mydata: .ascii "this is the message!
.equ mylen, . - mydata

[code]...

View 2 Replies View Related

Programming :: Using Backtrace() Function In C?

Jul 23, 2010

I want to use backtrace() function to debug a crash issue. I tried this sample code to see how backtrace works. backtrace() function always returns 0 with the below code. Is there any kernel configuration that needs to be set for proper working of backtrace?

#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
/* Obtain a backtrace and print it to stdout. */
void
print_trace (void)

[Code]...

View 2 Replies View Related

Programming :: How To Write / Use Function

May 30, 2010

Can you offer me the code about fmod() in C. I want to know how this function work, i am very interested in it because i have no idea to implement it, i want to know... how to write the function... not 'how to use the function' can anyone post the source codes of this function here?

View 6 Replies View Related

Programming :: Accessing C Function From C++

Jul 5, 2010

i have an open source application that was developed in C++ (it uses objects and namespaces all over the place). I also have another application that was developed in C. Now i am trying to insert the code made in C into C++ application, but when i do that , i get this error on compilation of the source code:

Code:
error: 'mpi_init_vars' was not declared in this scope the function mpi_init_vars() is not part of object oriented programming and it doesn't belong to any scope, it was compiled into an object file and i am linking it with all objects of C++ application.

How can invoke the C function from C++ object oriented code?

View 2 Replies View Related

Programming :: Bash Function Using If / Then And Else

May 2, 2011

I am trying to build a function inside a script.

Code:
#!/bin/sh
#System commands and other configurable.
IPT=/sbin/iptables
IP6T=/sbin/ip6tables
IPST=/usr/sbin/ipset
MODP=/sbin/modprobe
GET=/usr/bin/wget
INT_NET=192.168.1.0/24 .....

I can find lots of tutorials in how to use if, then, else. However, how do I define a variable inside the function?
SEE>>
Code:
for c in $ISO
Also, am I using the 'test' command correctly( -/+ week as valid test)?

View 7 Replies View Related

Programming :: Calling C Function In Php?

Feb 7, 2011

I am doing a web site program and what I need is to call a C program in the PHP cloud.Do u think it would be possible? The web site would get the user input from PHP UI and pass to the C program , the C program would process the function with the user input and output the a PHP page.

View 2 Replies View Related

Programming :: C++/c Function Is Uable To Know Its Name?

Jan 4, 2011

I ask if a c++/c function is able to know its name from inside itself:

example:

Code:
int funct1(int a,b)
{
printf("%s ",funct_name());
}
or with a trick.

View 2 Replies View Related

Programming :: Run 'time' On A Function?

May 30, 2010

Code:
#!/bin/ksh
(...)
# FILL UP PARTITION
diskfillerfunction () {

[Code]....

Test 15: fill up partition /usr/bin/time: cannot run diskfillerfunction: No such file or directory

I am obviously omitting (...) a lot of the code, but the relevant part is all there. How do I 'time' a function?

View 5 Replies View Related

Programming :: Run Function In Background?

Mar 26, 2010

I wrote a spinner in Perl and when I did a spinner in shell I could just run the subroutine in the background.

[code]...

In Perl, how do you run a function in a background and get the PID for that? I know PID in Perl is $$

View 2 Replies View Related

Programming :: Regarding Sleep() Function In C?

Mar 25, 2011

I know what is the functionality of the sleep() method.

for(i = 0; i < length; i++){
sleep(1000);
printf("%c
", message[i]);
}

Result :every print of the message will be takes 1000sec of gap but i want to know why wee need to use the Sleep function. where exactly it is useful

View 14 Replies View Related

Programming :: Return Value From A Function?

Nov 15, 2010

On this link [URL]4 a return type is defined

Code:
return ((unsigned int)(unsigned long)base & TBASE_DEFERRABLE_FLAG);
What is the above function returning.I am not clear with definition of what is being returned in the above code.

View 7 Replies View Related

Programming :: Use Function C In Java?

Apr 8, 2010

i want to compile function c in java and compile library is success.. when i call the library in java and error is :

Exception in thread "main" java.lang.UnsatisfiedLinkError: no libfunc.so in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1689)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)

[Code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved