Setting Up Socket Streams
- Get link
- X
- Other Apps
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:
but dont realy understand have put ip of host (192.168.1.10) , how can define istream , ostream.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]; } }
mention 192.168.1.1 have opened socket , listening specified port.
apreciated.
continuation
made :
but 192.168.1.1 still not recieve nothing...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
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
- Get link
- X
- Other Apps
Comments
Post a Comment