/// <summary> /// Connects the outbound socket. /// </summary> public override void Connect() { int port = (int)m_listener[Options.PORT]; Debug.Assert(port > 0); m_sock = CreateSocket(); string to = (string)m_listener[Options.TO]; Debug.Assert(to != null); string host = (string)m_listener[Options.NETWORK_HOST]; if ((host == null) || (host == "")) { host = to; } string url = (string)m_listener[Options.POLL_URL]; if ((url == null) || (url == "")) { #if !__MonoCS__ url = Address.LookupTXT("_xmppconnect.", to, "_xmpp-client-xbosh"); if (url == null) #endif throw new ArgumentNullException("URL not found in DNS, and not specified", "URL"); } ((IHttpSocket)m_sock).URL = url; //Address addr = new Address(host, port); m_sock.Connect(null, (string)m_listener[Options.SERVER_ID]); }
/// <summary> /// Creating the monitoring socket, this method automaticlly called by the start method /// if you want to receive events that happen before the call to the start mehod call /// this method earlier in your code /// </summary> public void Init() { if (!m_initialized) { // in case the sockets is created in another thread Thread.MemoryBarrier(); ZMQ.SocketMonitor(Socket.SocketHandle, MonitorAddress, m_monitoringEventsHandler.Events); MonitoringSocket = Context.CreatePairSocket(); MonitoringSocket.Connect(MonitorAddress); m_initialized = true; } }
/// <summary> /// Establishes the socket connection /// </summary> /// <param name="socket"> /// Socket instance /// </param> /// <param name="address"> /// IP address to connect to /// </param> /// <param name="port"> /// port to connect to /// </param> internal virtual void ConnectSocket(BaseSocket socket, IPAddress address, int port) { socket.Connect(new IPEndPoint(address, port)); }
/// <summary> /// Connects to the XMPP server. /// </summary> public override void Connect() { m_elements = null; int port = (int)m_listener[Options.PORT]; Debug.Assert(port > 0); //m_sslOn = m_ssl; ProxySocket proxy = null; ProxyType pt = (ProxyType)m_listener[Options.PROXY_TYPE]; switch (pt) { case ProxyType.Socks4: proxy = new Socks4Proxy(this); break; case ProxyType.Socks5: proxy = new Socks5Proxy(this); break; case ProxyType.HTTP: proxy = new ShttpProxy(this); break; /* * case ProxyType.HTTP_Polling: * XEP25Socket j25s = new XEP25Socket(this); * if (m_ProxyHost != null) * { * System.Net.WebProxy wp = new System.Net.WebProxy(); * wp.Address = new Uri("http://" + m_ProxyHost + ":" + m_ProxyPort); * if (m_ProxyUsername != null) * { * wp.Credentials = new System.Net.NetworkCredential(m_ProxyUsername, m_ProxyPassword); * } * j25s.Proxy = wp; * } * j25s.URL = m_server; * m_sock = j25s; * break; */ case ProxyType.None: m_sock = new AsyncSocket(null, this, (bool)m_listener[Options.SSL], false); ((AsyncSocket)m_sock).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as X509Certificate2; ((AsyncSocket)m_sock).CertificateGui = (bool)m_listener[Options.CERTIFICATE_GUI]; break; default: throw new ArgumentException("no handler for proxy type: " + pt, "ProxyType"); } if (proxy != null) { proxy.Socket = new AsyncSocket(null, proxy, (bool)m_listener[Options.SSL], false); ((AsyncSocket)proxy.Socket).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as X509Certificate2; proxy.Host = m_listener[Options.PROXY_HOST] as string; proxy.Port = (int)m_listener[Options.PROXY_PORT]; proxy.Username = m_listener[Options.PROXY_USER] as string; proxy.Password = m_listener[Options.PROXY_PW] as string; m_sock = proxy; } string to = (string)m_listener[Options.TO]; Debug.Assert(to != null); string host = (string)m_listener[Options.NETWORK_HOST]; if (String.IsNullOrEmpty(host)) { #if __MonoCS__ host = to; #else try { Address.LookupSRV((string)m_listener[Options.SRV_PREFIX], to, ref host, ref port); } catch { Debug.WriteLine("WARNING: netlib.Dns.dll missing"); host = to; } #endif } Address addr = new Address(host, port); m_sock.Connect(addr, (string)m_listener[Options.SERVER_ID]); }
/// <summary> /// Establishes the socket connection /// </summary> /// <param name="socket"> /// Socket instance /// </param> /// <param name="address"> /// IP address to connect to /// </param> /// <param name="port"> /// port to connect to /// </param> internal virtual void ConnectSocket(BaseSocket socket, string address, int port) { remoteAddr = HostNameResolver.GetAddress(address); socket.Connect(new IPEndPoint(remoteAddr, port), timeout); }