• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa Programming iPing exercise
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa Programming iPing exercise


  • Subject: Cocoa Programming iPing exercise
  • From: Shawn Protsman <email@hidden>
  • Date: Wed, 01 Oct 2008 10:25:38 -0700

I finally decided to take a dive into Objective-C with Xcode. I'm looking at the iPing example in Hillegass' latest book, Cocoa Programming. iPing works fine as coded in the book. Next, I decided to replace `ping` with a binary I wrote called `keyreq`. It is simply a C program and resides in /usr/local/bin.

Calling it from the command line with no keyserver listening on the other end:

] keyreq 1
<keyclient> starting ... requesting <1> key[s]
TcpConnect getsockopt returned ECONNREFUSED for IP <10.0.1.19> and port <6000>
TcpConnect ERR <5089>: Unable to connect to any specified servers
<keyclient> Error <5089>. Inspect logs


Calling it from the command line with a keyserver listening on the other end:

] keyreq 1
<keyclient> starting ... requesting <1> key[s]
Request #<1>
ALLKeyRtv results:
 Key name: <Key01-128                               >
 Instance Requested: <                        >
 Key Size : <128>
 Key Format: <1>
 Instance used: <mpn8/fE2ZzMI6NmeapwqDA==>
 Expiration: <00000000>
 Last rolled date: <00000000>
 Return: <0>

Here is the project code for the startStopPing method (the relevant part that I think I should change) of iPing:

	task = [[NSTask alloc] init];
	[task setLaunchPath:@"/sbin/ping"];
	NSArray *args = [NSArray arrayWithObjects:@"-c10",
					 [hostField stringValue], nil];
	[task setArguments:args];

Perhaps stupidly, I thought I could just swap out setLaunchPath and then change NSArray:

	task = [[NSTask alloc] init];
	[task setLaunchPath:@"/usr/local/bin/keyreq"];
	NSArray *args = [NSArray arrayWithObject:[hostField stringValue]];
	[task setArguments:args];

'Build and Go' compiles clean but upon entering a number, like 1 in hostField, and then clicking 'Start' results in the 'Debugger Console' going to gdb. With the above modification, I can return setLaunchPath to /sbin/ping and the program works fine.

Me, a novice, is confused. Any pointers to documentation, examples, etc. would be helpful.

--Shawn
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa Programming iPing exercise
      • From: Joe Keenan <email@hidden>
    • Re: Cocoa Programming iPing exercise
      • From: "Stephen J. Butler" <email@hidden>
    • Re: Cocoa Programming iPing exercise
      • From: Simon Wolf <email@hidden>
  • Prev by Date: Re: [Moderator] Please hold off on iPhone SDK discussions until the rules are clarified later today
  • Next by Date: Re: Play Playlist in iTunes
  • Previous by thread: "iPhone programming class", Silicon Valley
  • Next by thread: Re: Cocoa Programming iPing exercise
  • Index(es):
    • Date
    • Thread