Skip to content

Instantly share code, notes, and snippets.

Created November 11, 2014 01:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3b8164854ca87652725b to your computer and use it in GitHub Desktop.
Save anonymous/3b8164854ca87652725b to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
namespace TCPPunch
{
class Program
{
static void Main(string[] args)
{
var port = 4119;
var l = new TcpListener(System.Net.IPAddress.Any, port);
l.Start();
try
{
var o = new TcpClient(new System.Net.IPEndPoint(System.Net.IPAddress.Any, port));
var sdf = o.Client.LocalEndPoint;
o.Connect("mysite.com", 80);
}
catch(Exception ee) {
}
var e = l.AcceptSocket();
Console.WriteLine(e.RemoteEndPoint.AddressFamily);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment