/// <summary>
		/// Connects to IMAP server.
		/// </summary>		
		/// <param name="host">Host name.</param>
		/// <param name="port">Port number.</param>
		public void Connect(string host,int port)
		{
			if(!m_Connected){
			//	m_pSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
			//	IPEndPoint ipdest = new IPEndPoint(System.Net.Dns.Resolve(host).AddressList[0],port);
			//	m_pSocket.Connect(ipdest);

				Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
				IPEndPoint ipdest = new IPEndPoint(System.Net.Dns.Resolve(host).AddressList[0],port);
				s.Connect(ipdest);
				s.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.NoDelay,1);

				m_pSocket = new BufferedSocket(s);

				string reply = m_pSocket.ReadLine();
				reply = reply.Substring(reply.IndexOf(" ")).Trim(); // Remove Cmd tag

				if(!reply.ToUpper().StartsWith("OK")){
					m_pSocket.Close();
					m_pSocket = null;
					throw new Exception("Server returned:" + reply);
				}

				m_Connected = true;
			}
		}
Exemple #2
0
        /// <summary>
        /// Connects to IMAP server.
        /// </summary>
        /// <param name="host">Host name.</param>
        /// <param name="port">Port number.</param>
        public void Connect(string host, int port)
        {
            if (!m_Connected)
            {
                //	m_pSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
                //	IPEndPoint ipdest = new IPEndPoint(System.Net.Dns.Resolve(host).AddressList[0],port);
                //	m_pSocket.Connect(ipdest);

                Socket     s      = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ipdest = new IPEndPoint(System.Net.Dns.Resolve(host).AddressList[0], port);
                s.Connect(ipdest);
                s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);

                m_pSocket = new BufferedSocket(s);

                string reply = Core.ReadLine(m_pSocket);
                reply = reply.Substring(reply.IndexOf(" ")).Trim();                 // Remove Cmd tag

                if (!reply.ToUpper().StartsWith("OK"))
                {
                    m_pSocket.Close();
                    m_pSocket = null;
                    throw new Exception("Server returned:" + reply);
                }

                m_Connected = true;
            }
        }
Exemple #3
0
 public void Disconnect()
 {
     bs5009.Close();
     RemoveClientApp(hIqFeed);
     if (null != DisconnectedEventHandler)
     {
         DisconnectedEventHandler(this, EventArgs.Empty);
     }
 }
Exemple #4
0
 public void Close()
 {
     gh         = null;
     instrument = null;
     bs         = null;
     bars       = null;
     trades     = null;
     quotes     = null;
     stkTrades  = null;
     bufSock.Close();
     bufSock = null;
 }
Exemple #5
0
        /// <summary>
        /// Ends session, closes socket.
        /// </summary>
        private void EndSession()
        {
            if (m_pSocket != null)
            {
                m_pSocket.Shutdown(SocketShutdown.Both);
                m_pSocket.Close();
                m_pSocket = null;
            }

            m_pServer.RemoveSession(this);

            // Write logs to log file, if needed
            if (m_pServer.LogCommands)
            {
                m_pLogWriter.AddEntry("//----- Sys: 'Session:'" + this.SessionID + " removed " + DateTime.Now);

                m_pLogWriter.Flush();
            }
        }
Exemple #6
0
 public void Close()
 {
     bs.Close();
 }