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 开发者_如何学Pythonxcode 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);
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:
Let me show you the code it is very simple to understand just to show what's going on...
the client code:
and the server code:
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?
+getStreamsToHost:port:inputStream:outputStream:
is a class method (indicated by the +
), so you have to use [NSStream getStreams...]
instead of [[[NSStream alloc] init] getStreams...]
.
精彩评论