public SocketConnection(String ServerAddress, Int32 ServerPort, Boolean passive, DiagramContainer inContainer, DiagramContainer outContainer, DiagramHandler diagHandler) { try { handler = diagHandler; sendQueue = outContainer; receiveQueue = inContainer; outAddress = IPAddress.Parse(ServerAddress); outEndPoint = new IPEndPoint(outAddress, ServerPort); outConnection = new Socket(outEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); inEndPoint = new IPEndPoint(IPAddress.Loopback, ServerPort); inConnection = new Socket(inEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); inConnection.Bind(inEndPoint); Thread inThread = new Thread(StartInConnection); inThread.Start(); Thread outThread = new Thread(StartOutConnection); outThread.Start(outEndPoint); } catch (FormatException formatEx) { log.Error(formatEx.Message); } catch (SocketException socketEx) { log.Error(socketEx.Message); } }
private void InitializeProxy() { handler = new RiskHandler(); inContainer = new ConcurrentDiagramContainer(); outContainer = new ConcurrentDiagramContainer(); clientSocket = new SocketConnection("127.0.0.1", 6666, inContainer, outContainer, handler); serverSocket = new SocketConnection("127.0.0.1", 8888, outContainer, inContainer, handler); }
/// <summary> /// Default constructor, initializes the component and initializes DiagramHandler /// </summary> public MainWindow() { InitializeComponent(); diagramHandler = new DiagramHandler(); }