public static void ListenerPeer(SourceNode sourceNode) //create conn { TcpListener tcpListener = new TcpListener(Convert.ToInt32(sourceNode.Port)); tcpListener.LocalInterface = sourceNode.IPAddress; ListenerPeer listener = new ListenerPeer(sourceNode.Id.ToString(), new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()), new BasicMessagesIdentifier(11, 41), tcpListener); listener.Receive += new PeerReceiveEventHandler(Listener_Receive); listener.Connected += listener_Connected; listener.Connect(); Console.WriteLine("Listening for connection.. on " + sourceNode.Port); }
public static void StartUpListener(string name, string hostName, int port) //create conn { Trx.Messaging.FlowControl.TcpListener tcpListener = new Trx.Messaging.FlowControl.TcpListener(port); tcpListener.LocalInterface = hostName; ListenerPeer listener = new ListenerPeer(name, new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()), new BasicMessagesIdentifier(11, 41), tcpListener); listener.Receive += new PeerReceiveEventHandler(Listener_Receive); listener.Connected += new PeerConnectedEventHandler(Listener_Connected); listener.Disconnected += new PeerDisconnectedEventHandler(Listener_Disconnected); listener.Connect(); //Console.WriteLine("Waiting for connection..."); }
public void StartListener(SourceNode node) { TcpListener tcpListener = new TcpListener(node.Port); tcpListener.LocalInterface = node.IPAddress; ListenerPeer listener = new ListenerPeer(node.Id.ToString(), new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()), new BasicMessagesIdentifier(11, 41), tcpListener); // ListenerPeer listener.Error += (sender, e) => ErrorListener(sender, e); listener.Receive += (sender, e) => ReceiveListener(sender, e, node); listener.Disconnected += (sender, e) => DisconnectListener(sender, node); listener.Connect(); Console.WriteLine($"Now listening to {node.Name} on IP {node.IPAddress} port {node.Port}"); }
public void StartListener(string ipAddress, int port, string id) { TcpListener tcpListener = new TcpListener(port); tcpListener.LocalInterface = ipAddress; ListenerPeer listener = new ListenerPeer(id, new TwoBytesNboHeaderChannel(new Iso8583Ascii1987BinaryBitmapMessageFormatter()), new BasicMessagesIdentifier(11, 41), tcpListener); // ListenerPeer listener.Error += (sender, e) => ErrorListener(sender, e); listener.Receive += (sender, e) => ReceiveListener(sender, e); listener.Disconnected += (sender, e) => DisconnectListener(sender); listener.Connect(); Debug.WriteLine($"Now listening on IP {ipAddress} port {port}"); }
public void StartListener() { TcpListener tcpListener = new TcpListener(port); tcpListener.LocalInterface = localInterface; tcpListener.Start(); ListenerPeer listenerPeer = new ListenerPeer("Switch", new TwoBytesNboHeaderChannel( new Iso8583Ascii1987BinaryBitmapMessageFormatter()), tcpListener); //logger.Log("Phantom FEP now listening at " + localInterface + " on " + port); listenerPeer.Connected += new PeerConnectedEventHandler(ListenerPeerConnected); listenerPeer.Receive += new PeerReceiveEventHandler(ListenerPeerReceive); listenerPeer.Disconnected += new PeerDisconnectedEventHandler(ListenerPeerDisconnected); listenerPeer.Connect(); }
private static void SendSourceNodeResponse(ListenerPeer sourceNodePeer, Iso8583Message message) { int tries = 10; while (!sourceNodePeer.IsConnected && tries > 0) { Console.WriteLine("Could not connect to source node. Retrying in 5 seconds."); tries--; sourceNodePeer.Connect(); Thread.Sleep(5000); } if (tries <= 0 && !sourceNodePeer.IsConnected) { Console.WriteLine("Reconnection attempt failed. Could not send response to source"); } else { PeerRequest request = new PeerRequest(sourceNodePeer, message); request.Send(); request.Peer.Close(); } }