• 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: simple telnet-like networking in cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple telnet-like networking in cocoa


  • Subject: Re: simple telnet-like networking in cocoa
  • From: Christoffer Lerno <email@hidden>
  • Date: Tue, 25 May 2004 13:31:35 +0800

On May 25, 2004, at 11:42, Bob Ippolito wrote:

>> What I already have is a server speaking UTF-8 text (a message is
>> terminated by \n), what I need is to communicate with it. So if I
>> could just open some simple stream to it then that would be perfect.
>
> The real question is: What the heck else do you have to do?
>
> If you're integrating with Cocoa stuff, you will most definitely want
> to use something like CFSocket or a CFSocket wrapper like NetSocket
> (third party).
>
> NSStream only works on 10.3 and later, so I don't really suggest you
> use that unless you are taking advantage of other 10.3 specific
> functionality. BSD sockets are hard to do right, *especially* if you
> have something else to do. I highly suggest that you do not bother
> with BSD sockets directly, other people have written frameworks on top
> of them so that you don't have to. If they were trivial to use, then
> those frameworks wouldn't be so abundant.

I'd like to use something nicely encapsulated of course, but frankly
the manuals for CFSocket and NSStream both confuse the shit out of me.
I really don't need any of this functionality, at least not initially.
First I just want to connect a simple socket to my server and see that
it works. I don't want to do some heavy coding just to see the socket
open nice and properly. I thought I understood how to use NSStream, but
it became painfully clear that it's not as simple as it originally
seemed to be. At least I got the BSD stuff to work right off the bat.

I'm bashing my head against the wall getting NSStream to work here.

Could someone just provide me with a code snippet that at least
initializes a socket at some address & port, and then read & write a
few characters through it?



/Christoffer

P.S.
Here's the NSStream code that I can't get to work. I want the code to
connect to the server but it never happens:

NSHost* host=[NSHost hostWithAddress:[url stringValue]];
[NSStream getStreamsToHost:host port:1333 inputStream:&instream
outputStream:&outstream];
[instream setDelegate:self];
[instream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[instream open];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: simple telnet-like networking in cocoa
      • From: Christoffer Lerno <email@hidden>
References: 
 >simple telnet-like networking in cocoa (From: Christoffer Lerno <email@hidden>)
 >Re: simple telnet-like networking in cocoa (From: Bob Ippolito <email@hidden>)
 >Re: simple telnet-like networking in cocoa (From: Christoffer Lerno <email@hidden>)
 >Re: simple telnet-like networking in cocoa (From: Bob Ippolito <email@hidden>)

  • Prev by Date: Re: why are floats flakey?
  • Next by Date: Re: NSScanner woes
  • Previous by thread: Re: simple telnet-like networking in cocoa
  • Next by thread: Re: simple telnet-like networking in cocoa
  • Index(es):
    • Date
    • Thread