/// <summary> /// Starts the transport. /// </summary> /// <param name="binding">The network binding the transport will use.</param> /// <param name="cbSocketBuffer">Size of the socket's send and receive buffers in bytes.</param> /// <param name="router">The <see cref="ISipMessageRouter" /> instance that will handle the routing of received messages.</param> /// <exception cref="SocketException">Thrown if there's a conflict with the requested and existing socket bindings.</exception> public void Start(NetworkBinding binding, int cbSocketBuffer, ISipMessageRouter router) { try { sock = new EnhancedSocket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); sock.SendBufferSize = cbSocketBuffer; sock.ReceiveBufferSize = cbSocketBuffer; sock.IgnoreUdpConnectionReset = true; sock.Bind(binding); this.localEP = (IPEndPoint)sock.LocalEndPoint; this.onRecv = new AsyncCallback(OnReceive); this.recvBuf = new byte[64 * 1024]; this.recvEP = new IPEndPoint(IPAddress.Any, 0); this.router = router; this.traceMode = SipTraceMode.None; recvPending = true; sock.BeginReceiveFrom(recvBuf, 0, recvBuf.Length, SocketFlags.None, ref recvEP, onRecv, null); } catch { if (sock.IsOpen) { sock.Close(); } sock = null; throw; } }
/// <summary> /// Starts the transport. /// </summary> /// <param name="binding">The network binding the transport will use.</param> /// <param name="cbSocketBuffer">Size of the socket's send and receive buffers in bytes.</param> /// <param name="router">The <see cref="ISipMessageRouter" /> instance that will handle the routing of received messages.</param> /// <exception cref="SocketException">Thrown if there's a conflict with the requested and existing socket bindings.</exception> public void Start(NetworkBinding binding, int cbSocketBuffer, ISipMessageRouter router) { this.cbSocketBuffer = cbSocketBuffer; this.listener = new SocketListener(); this.connections = new Dictionary <string, Connection>(); this.sweepInterval = TimeSpan.FromSeconds(30); this.maxInactive = TimeSpan.FromMinutes(5); // Minimum time is 3 minutes according to RFC 3261 this.router = router; this.localEP = binding; this.traceMode = SipTraceMode.None; try { listener.SocketAcceptEvent += new SocketAcceptDelegate(OnAccept); listener.Start(binding, 100); } catch { listener.StopAll(); listener = null; } }
public void Initialize() { //NetTrace.Start(); traceMode = SipTraceMode.Send; }
/// <summary> /// Sets the diagnostic tracing mode. /// </summary> /// <param name="traceMode">The <see cref="SipTraceMode" /> flags.</param> public void SetTraceMode(SipTraceMode traceMode) { this.traceMode = traceMode; }