C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-31-2009, 05:35 PM   #1
Registered User
 
Join Date: Mar 2009
Posts: 48
ping script doesn't work?

Hey,

i test the ping script at LCC-Win32 and VS2005(Win32 Console App), but can't work.

ping.h
Code:
#ifndef __ping_h__
#define __ping_h__
#define MAXIPNAME	30
// For optional values, zero means use the default.
typedef struct __Ping {
        char *HostName;    // IN: Host name/Ip address of destination. Required
	int TotalPackets;  // OPTIONAL: Number of packets to send before exiting. 
                           //           Default is 5
	int DataSize;      // OPTIONAL: Data size in the sent packets. Default is 32
	int SleepTime;     // OPTIONAL: Time (in ms) to wait after each packet.
                           //           Default is 1000 ms.
	int MaxTimeouts;   // OPTIONAL: Maximum number of timeouts allowed.
	                   //           Default is 5.
	int (*Callback)(struct __Ping *); // OPTIONAL: Callback function at each
                          // packet received and at each timeout.
	int ttl;          // OPTIONAL: Time to live. Default 128
	int verbose;       // Optional: Whether to print messages to stdout or not.
	int TotalReceived; // OUT: Total packets received
	int TotalSent;	   // OUT: Total packets sent
	int MaxTime;       // OUT: Maximum time (ms)
	int MinTime;       // OUT: Minimum time (ms)
	int TotalTime;     // OUT: Total time used
	int Timeouts;      // OUT: Number of timeouts
	int Errorcode;     // WSAGetLastError() report when an error occurs, or
                           // a negative number, specific to the ping function.
	int ShortPackets;  // OUT: Packets that weren't sent completely due to errors
	char ip[MAXIPNAME];// OUT: IP of destination (Can be the same as HostName)
	// Per packet specific data
	int Bytes;         // OUT: Bytes received
	int Seq;           // OUT: Sequence number
	int Time;          // OUT: Time for this packet
} PingInterface;

#define PINGERROR_BADADDR	-1
#define PINGERROR_SETSOCKOPT	-2
#define PINGERROR_NONETWORK	-3
#define PINGERROR_NOSOCKET	-4
#define PINGERROR_INTERNAL	-5

int ping(PingInterface *);
#endif

ping.c
Code:
#include <ping.h>
#include <stdio.h>

int main(int argc,char *argv[])
{
	PingInterface p;
	memset(&p,0,sizeof(p));
	p.HostName = (argv[1]);
	if (ping(&p)) {
		printf("Host %s is up\n",argv[1]);
	}
	else
		printf("Host %s is down\n",argv[1]);
}
The code from LCC-Win32 CTutorial PDF book.

LCC-Win32 compile failed:
Wedit output window build: Mon Jun 01 07:30:06 2009
Error c:\lcc\ping\ping.c 11 undefined reference to _ping
C:\lcc\bin\make.exe
Compilation + link time:0.1 sec, Return code: 1


Comment: I conly created the ping.c file for the project, ping.h already inclueded at the directory of "c:\lcc\include\ping.h".


VS2005 compile failed too:
------ Rebuild All started: Project: ping, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'ping', configuration 'Debug|Win32'
Compiling...
ping.c
d:\vs\tmp\pingfun\pingfun\ping.c(2) : fatal error C1083: Cannot open include file: 'ping.h': No such file or directory
Build log was saved at "file://d:\vs\TMP\PingFun\PingFun\Debug\BuildLog.htm"
ping - 1 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


Comment: Actually, i already add a new ping.h file at the vs IDE. and i right click the <ping.h> from ping.c head incldue area, the ping.h fill frame will jumped out normally. Why the comipler sitll alert "NO such file or drectory"?

thanks!
__________________
--------------------------------------------------------
Newbie
C/C#/C++
swimming/cycling/running
There is nothing more powerful than an idea.
Except for an idea put into action.
--------------------------------------------------------

Last edited by userpingz; 05-31-2009 at 05:40 PM. Reason: wrong ENTER key input when i creating the post
userpingz is offline   Reply With Quote
Old 05-31-2009, 06:12 PM   #2
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
Quote:
Originally Posted by guy with stupid name
comment: Actually, i already add a new ping.h file at the vs IDE. and i right click the <ping.h> from ping.c head include area, the ping.h fill frame will jumped out normally.
I doubt you added the library where "ping()" resides.
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline   Reply With Quote
Old 05-31-2009, 07:49 PM   #3
Registered User
 
Join Date: Mar 2009
Posts: 48
Quote:
Originally Posted by zacs7 View Post
I doubt you added the library where "ping()" resides.
thank you.
i am newbie.

I backed up ping.h and reinstalled the LCC-WIN32.exe just now.
the ping.h located at C:\lcc\includ\... No different after i reinstall the tool.
attached the ping.h

Is there something wrong with my ping.h OR ping.c


em :-(
Attached Files
File Type: h ping.h (1.9 KB, 15 views)
__________________
--------------------------------------------------------
Newbie
C/C#/C++
swimming/cycling/running
There is nothing more powerful than an idea.
Except for an idea put into action.
--------------------------------------------------------
userpingz is offline   Reply With Quote
Old 05-31-2009, 07:53 PM   #4
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
So as zacs7 said, your ping.h header file claims that your ping.c file will define a function called ping; yet it does not, causing much sadness and despondency.
tabstop is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
using expect script in C program nitinmhetre Linux Programming 1 12-21-2006 08:25 AM
Script in games Shakti Game Programming 7 09-27-2006 12:27 AM
In a game Engine... Shamino Game Programming 28 02-19-2006 11:30 AM
how to implementate a registration script TJa C++ Programming 0 10-28-2005 02:33 AM
Problem with cgi script - can't rename files bjdea1 C Programming 2 12-12-2001 04:09 PM


All times are GMT -6. The time now is 01:56 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22