Socket

Discussion in 'iOS Development' started by benafiahmed, Jul 23, 2009.

  1. benafiahmed

    benafiahmed New Member

    Joined:
    Jul 14, 2009
    Messages:
    6
    Likes Received:
    0
    Hello,

    how to communicate with a PC server (Fixed IP) using TCP/IP Socket ??

    I found this :

    [OBJC]- (IBAction)searchForSite

    Please Register or Log in to view images

    id)sender
    {
    NSString *urlStr = [sender stringValue];
    if (![urlStr isEqualToString

    Please Register or Log in to view images

    ""]) {
    [searchField setEnabled:NO];
    NSURL *website = [NSURL URLWithString:urlStr];
    if (!website) {
    NSLog(@"%@ is not a valid URL");
    return;
    }
    NSHost *host = [NSHost hostWithName:[website host]];
    // iStream and oStream are 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];
    }
    }[/OBJC]

    I do not understand anything, how it can be useful ??
    Thank you for help !!
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    You should uses [ OBJC ] and [ /OBJC ] for more readable. If you uses it, no space between [ and ].

Share This Page