Last active
July 17, 2018 02:28
-
-
Save Cyberboss/70318dfa917cc59f27f0203803b70fc6 to your computer and use it in GitHub Desktop.
Try to bind 3337
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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