0

I need to send a string to a server on the same network with the iPad. when reading This I found out that maybe I need to use the + getStreamsToHost:port:inputStream:outputStream: method but I am not able use it. In xcode I have tried:

//Try 1
NSStream *myStream;
//[myStream getStreamToHost// xcode cant find it]

//Try 2
NSStream *myStream2 = [[NSStream alloc] init];
[myStream2 getStreamToHost// I have initialized it and yet xcode can't find the method


//Try 3
[NSStream getStreamToHost] // does not work eather

 //Try 4
 [[[NSStream alloc] init] getStreamToHost// does not work

and by the way I am listening on port 403 with a simple program called autoit let me show you how:

I have two scripts (the client and the server); enter image description here

first I run the server and it starts listening. Then I run the client script and when that happens a message box appears and a song starts playing: enter image description here

Let me show you the code it is very simple to understand just to show what's going on...

the client code:

enter image description here

and the server code:

enter image description here

note that the client sends the message hello and when that happens a message box appears MsgBox(0,"Data Received", $TCPReceive) and a song starts playing shellExecute("t.mp3") that mp3 file is on the same directory of the script.

HOW CAN I SEND A SIMILAR MESSAGE BUT WITH AN IPHONE TO MY COMPUTER?

Tono Nam
  • 34,064
  • 78
  • 298
  • 470

1 Answers1

0

+getStreamsToHost:port:inputStream:outputStream: is a class method (indicated by the +), so you have to use [NSStream getStreams...] instead of [[[NSStream alloc] init] getStreams...].

jtbandes
  • 115,675
  • 35
  • 233
  • 266
  • I have tried that when I type [NSStream get (then press f5 to see my available options getStreamsToHost is not there) do I have to import some Framework that I am not ware of? – Tono Nam Jul 16 '11 at 20:40
  • iOS SDK doesn't provide this method. – zetachang Sep 13 '13 at 02:41