/// <summary> /// Creates a new instance of the <see cref="StreamParser"/> class /// </summary> /// <param name="session">A <see cref="TcpIpSession"/></param> /// <param name="responseQueue">A <see cref="ResponseQueue"/> instance to which <see cref="ResponsePDU"/> pdu's are forwarded</param> /// <param name="requestProcessor">A callback delegate for processing <see cref="RequestPDU"/> pdu's</param> public StreamParser(TcpIpSession session, ResponseHandler responseQueue,PduProcessorCallback requestProcessor) { if (session == null) { throw new ArgumentNullException("session"); } if (requestProcessor == null) { throw new ArgumentNullException("requestProcessor"); } if (responseQueue == null) { throw new ArgumentNullException("responseQueue"); } vTcpIpSession = session; vProcessorCallback = requestProcessor; vResponseHandler = responseQueue; //--Create and initialize a trace switch vTraceSwitch = new TraceSwitch("StreamParserSwitch", "Stream perser switch"); }
public static TcpIpSession OpenClientSession(string hostName, int port) { Socket socket = CreateClientSocket(); //Creates a socket to be used as client try { socket.Connect(hostName, port); } //Connect to the specified host on the specified port catch (SocketException ex) { HandleConnectionException(ex); } TcpIpSession session = new TcpIpSession(socket, SessionType.Client); session.vProperties = new TcpIpSessionProperties(socket); session.vIsAlive = true; return(session); }
public static TcpIpSession OpenClientSession(IPAddress[] addresses, int port) { Socket socket = CreateClientSocket(); //Creates a socket to be used for client connection try { socket.Connect(addresses, port); } catch (SocketException ex) { HandleConnectionException(ex); } TcpIpSession session = new TcpIpSession(socket, SessionType.Client); session.vProperties = new TcpIpSessionProperties(socket); session.vIsAlive = true; return(session); }
/// <summary> /// Establishes a TCP/IP session with a remote host. The host is specified by an IP address and a port number /// </summary> /// <param name="ipAddress">The IP address of the remote host</param> /// <param name="port">The port number of the remote host</param> /// <returns>A TCP/IP session</returns> public static TcpIpSession OpenClientSession(IPAddress ipAddress, int port) { Socket socket = CreateClientSocket(); //Creates a socket to be used as client try { socket.Connect(ipAddress, port); } //Connect to the server of the specified ipAddress on the specified port catch (SocketException ex) { HandleConnectionException(ex); } TcpIpSession session = new TcpIpSession(socket, SessionType.Client); session._vProperties = new TcpIpSessionProperties(socket); session._vIsAlive = true; return(session); }
public PDUTransmitter(TcpIpSession session) { if (session == null) { throw new ArgumentNullException("session"); } vTcpIpSession = session; }
public static TcpIpSession OpenClientSession(string hostName, int port) { Socket socket = CreateClientSocket(); //Creates a socket to be used as client try { socket.Connect(hostName, port); } //Connect to the specified host on the specified port catch (SocketException ex) { HandleConnectionException(ex); } TcpIpSession session = new TcpIpSession(socket, SessionType.Client); session.vProperties = new TcpIpSessionProperties(socket); session.vIsAlive = true; return session; }
public static TcpIpSession OpenClientSession(IPAddress[] addresses, int port) { Socket socket = CreateClientSocket(); //Creates a socket to be used for client connection try { socket.Connect(addresses,port); } catch (SocketException ex) { HandleConnectionException(ex); } TcpIpSession session = new TcpIpSession(socket, SessionType.Client); session.vProperties = new TcpIpSessionProperties(socket); session.vIsAlive = true; return session; }