Cocoa/Objective-C and TCP Sockets...

Member
Posts: 43
Joined: 2009.02
Post: #1
Hey, I can't seem to understand NSStreams... I'm sort of lost.

I've been tasked with porting my MUD client written in Ruby to Objective-C and with a GUI. Everything is up and running, except for the networking. I'm completely lost with the NSStreams. Can anyone help clarify them for me?

[NSStream streamWithHost:host port:8000 inputStream:&iStream outputStream:&oStream]
That's basically how I have it setup, but it doesn't seem to be working. I need to be able to send and receive strings of text. Please help me out here!

Is there an alternative to NSStreams that just interfaces TCP sockets?
Quote this message in a reply
⌘-R in Chief
Posts: 1,261
Joined: 2002.05
Post: #2
I think pretty much most everyone skips to light wrappers around BSD sockets. Though, you could have just left almost all of your code in Ruby and used RubyCocoa or MacRuby. Smile

(Unless you're targeting the iTouch devices.)
Quote this message in a reply
Member
Posts: 43
Joined: 2009.02
Post: #3
Yeah I've got NSStreams working it seams with receiving text. But I can't seem to change my NSString into bytes to be put into a
uint8_t buf[100]; c array. I'm trying this:

uint8_t buf[100];

//CONVERSION of 'x' into 'buf'
NSRange range = NSMakeRange(1, 100);
[x getBytes:buf maxLength:100 usedLength:NULL encoding:NSASCIIStringEncoding options:NULL range:range remainingRange:NULL];

But I get this error: (With x being an NSString* )
warning: passing argument 5 of "getBytes:maxLength:usedLength:encoding:option:range:remainingRange:" makes integer frmo pointer without a cast.

Can anyone help me figure this out?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa or STL in Objective-C++ bmantzey 5 5,190 Jan 2, 2009 03:41 PM
Last Post: bmantzey
  Server/database interaction in C++ using sockets wyrmmage 2 5,291 Jan 20, 2007 02:17 PM
Last Post: wyrmmage
  The need for connect/listen on raw sockets? BinarySpike 28 16,064 Oct 26, 2006 07:23 PM
Last Post: akb825