• 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
Re: Telnet Networking Example
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Telnet Networking Example


  • Subject: Re: Telnet Networking Example
  • From: Eli Bach <email@hidden>
  • Date: Thu, 23 Jul 2009 11:39:55 -0700


On Jul 23, 2009, at 11:24 AM, DerNalia wrote:

I have all this code I got from the Apple Developer site, It all sets up correctly. Assuming I can trust my NSLogs, I should be connected to my telnet server.

So, lets I say I want to send the command "!COMMAND ARG"


Since this:
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode
sounds like it should do what I want, and NSStreamEvent is an NSUInteger, do I just break up the command char by char, and send it to this method?



Um, nope.

- (void)stream:(NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent

is a method you implement in one of your classes, of which you create an instance and then set that instance to be the delegate of either the NSInputStream or NSOutputStream (or both). It is how the stream object tells you what is happening to the stream (such as the stream has opened, closed, received an error, etc...).


Since you need to send some data to the remote server, I believe you will need to use the NSOutputStream method:


-(NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)length


This is from <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSOutputStream_Class/Reference/Reference.html#//apple_ref/doc/uid/20001983-BAJCCBCH >


You may want to click on that link, then download the 'CocoaEcho' sample code that is available there.

Eli

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Telnet Networking Example
      • From: DerNalia <email@hidden>
References: 
 >Telnet Networking Example (From: DerNalia <email@hidden>)
 >Re: Telnet Networking Example (From: Jens Alfke <email@hidden>)
 >Re: Telnet Networking Example (From: DerNalia <email@hidden>)

  • Prev by Date: Re: Telnet Networking Example
  • Next by Date: Re: Telnet Networking Example
  • Previous by thread: Re: Telnet Networking Example
  • Next by thread: Re: Telnet Networking Example
  • Index(es):
    • Date
    • Thread