Skip to content

Instantly share code, notes, and snippets.

@Cyberboss
Last active July 17, 2018 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cyberboss/70318dfa917cc59f27f0203803b70fc6 to your computer and use it in GitHub Desktop.
Save Cyberboss/70318dfa917cc59f27f0203803b70fc6 to your computer and use it in GitHub Desktop.
Try to bind 3337
using System;
using System.Net;
using System.Net.Sockets;
namespace Test3337
{
class Program
{
static void Main()
{
try
{
Console.WriteLine("Creating socket...");
using (var sock = new Socket(SocketType.Stream, ProtocolType.IP))
{
Console.WriteLine("Binding to 0.0.0.0:3337...");
sock.Bind(new IPEndPoint(IPAddress.Any, 3337));
Console.WriteLine("Bound! Beginning listen...");
sock.Listen(10);
Console.WriteLine("Listening! Waiting to accept...");
using (var con = sock.Accept())
{
Console.WriteLine("Accepted! I am connected to " + con.RemoteEndPoint.Address + " on port number " + ((IPEndPoint)con.RemoteEndPoint).Port);
Console.WriteLine("Shutting down connection socket...");
con.Shutdown(SocketShutdown.Both);
Console.WriteLine("Disposing connection socket...");
}
Console.WriteLine("Shutting down listen socket...");
sock.Shutdown(SocketShutdown.Both);
Console.WriteLine("Disposing listen socket...");
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment