Code Monkey home page Code Monkey logo

mgsportchecker's Introduction

What is it

MGSPortChecker is an OS X Cocoa router port checker. Typically an app will use MGSPortChecker to determine whether a particular port is open on the local Internet router. MGSPortChecker calls out to an external web server that probes the source IP for a specific open port.

Where can I see it in use

You can see MGSPortChecker used in the following products:

  • KosmicTask : a multi (20+) language scripting environment for OS X that features script editing, network sharing, remote execution and file processing.

If you use MGSPortChecker in your app and want it added to the list raise it as an issue.

Installation

Install portcheck.php on your web server (say at portchecker.example.com/portcheck.php). This script will be used to call back to the source of the request to check the port status.

Usage

Usage is simple. Allocate a MGSPortChecker, configure it and call start. Alternatively use the + startForURL:port:timeout:delay:withDelegate factory method.

-(void)startPortChecking
{
	// portcheck.php is installed on this URL
	NSString *portCheckerURL = @"http://portcheck.example.com";

	// allocate the port checker
	NSURL *url = [NSURL URLWithString:portCheckerURL];
	_portChecker = [[MGSPortChecker alloc] initForURL:url];

	// configure the checker
	_portChecker.portNumber = 80;
	_portChecker.portQueryTimeout = 10.0;
	_portChecker.delegate = self;

	// check the port
	[_portChecker start];
}

When the check completes the delegate receives portCheckerDidFinishProbing:.

- (void)portCheckerDidFinishProbing:(MGSPortChecker *)portChecker
{
	switch ([portChecker status]) {
    	case kMGS_PORT_STATUS_NA:
    	break;

    	case kMGS_PORT_STATUS_OPEN:
        	self.externalPort = portChecker.portNumber;
        	self.IPAddressString = portChecker.gatewayAddress;
    	break;

    	case kMGS_PORT_STATUS_CLOSED:
     	break;

    	case kMGS_PORT_STATUS_ERROR:
    	default:
   		break;
	}
}

Licence

MIT

Where did it come from?

MGSPortChecker is derived from the port checker used in the Transmission bit torrent client.

mgsportchecker's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

taroyuyu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.