Skip to content


Subversion checkout URL

You can clone with
Download ZIP
STUN protocol implementation for iOS
branch: master
Failed to load latest commit information.
STUN print server at start
.gitignore Initial commit Update

STUN protocol implementation for iOS

This is a Session Traversal Utilities for NAT (STUN) protocol implementation for iOS. Original specification:

How it works

  1. Import STUNClient and GCDAsyncUdpSocket classes:

    #import "GCDAsyncUdpSocket.h"
    #import "STUNClient.h"  
  2. Add STUNClientDelegate protocol to your class:

    @interface MyClass : NSObject <STUNClientDelegate>{
  3. Create instances of GCDAsyncUdpSocket and STUNClient classes. Perform method requestPublicIPandPortWithUDPSocket:delegate: and pass to it udp socket & delegate:

    GCDAsyncUdpSocket *udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    STUNClient *stunClient = [[STUNClient alloc] init];
    [stunClient requestPublicIPandPortWithUDPSocket:udpSocket delegate:self];
  4. Catch result in delegate's method -(void)didReceivePublicIPandPort:(NSDictionary *) data:

    -(void)didReceivePublicIPandPort:(NSDictionary *) data{
        NSLog(@"Public IP=%@, public Port=%@, NAT is Symmetric: %@", [data objectForKey:publicIPKey],
        [data objectForKey:publicPortKey], [data objectForKey:isNATTypeSymmetric]);
  5. See in log:

    2012-09-20 15:55:31.160 STUN[19255:f803] Public IP=, public Port=42483
  6. Start send Indication messages:

    [stunClient startSendIndicationMessage];
  7. Injoit!


It's compeletely free, use this lib without any problems.
Just would be great if you add info somewhere in your app about author: "STUN-iOS: Igor form QuickBlox", but it's not a requirement.

Something went wrong with that request. Please try again.