Setting Up Socket Streams


hi all,

have basic(for of you) question.
i´m trying make simple app have 1 button (for example) , when pushed app create socket connection host , send message.

, have found on adc:

code:
- (ibaction)searchforsite:(id)sender  {      nsstring *urlstr = [sender stringvalue];      if (![urlstr isequaltostring:@""]) {          [searchfield setenabled:no];          nsurl *website = [nsurl urlwithstring:urlstr];          if (!website) {              nslog(@"%@ not valid url");              return;          }          nshost *host = [nshost hostwithname:[website host]];          // istream , ostream instance variables          [nsstream getstreamstohost:host port:80 inputstream:&istream              outputstream:&ostream];          [istream retain];          [ostream retain];          [istream setdelegate:self];          [ostream setdelegate:self];          [istream scheduleinrunloop:[nsrunloop currentrunloop]              formode:nsdefaultrunloopmode];          [ostream scheduleinrunloop:[nsrunloop currentrunloop]              formode:nsdefaultrunloopmode];          [istream open];          [ostream open];      }  }    
but dont realy understand have put ip of host (192.168.1.10) , how can define istream , ostream.

mention 192.168.1.1 have opened socket , listening specified port.


apreciated.
 

continuation

made :

code:
- (ibaction)reset:(id)sender   {      [textfield setstringvalue:@"testing socket"];  	  	  	  	nsstring *urlstr = [sender stringvalue];      if (![urlstr isequaltostring:@""]) {                   nsurl *website = [nsurl urlwithstring: @"http://192.168.1.1"];          if (!website) {              nslog(@"%@ not valid url");              return;          }         		nshost *host = [nshost hostwithname:@"http://192.168.1.1"];  		nsinputstream *istream = [nsstring stringwithformat:@"ping"];  		nsoutputstream *ostream = [nsstring stringwithformat:@"ping"];          [nsstream getstreamstohost:host port:8000 inputstream:&istream  					  outputstream:&ostream];          [istream retain];  	    [ostream retain];          [istream setdelegate:self];          [ostream setdelegate:self];          [istream scheduleinrunloop:[nsrunloop currentrunloop]  	   				   formode:nsdefaultrunloopmode];          [ostream scheduleinrunloop:[nsrunloop currentrunloop]  	   					   formode:nsdefaultrunloopmode];          [istream open];          [ostream open];      }  	  	  }        @end  
but 192.168.1.1 still not recieve nothing...
i'm wrong?
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Upgrade Eligibility?

need help with itunes 7.7

How to change Apple IDs on iPhones