Beispiel #1
0
        private void ConnectAsInitiatorDirect()
        {
            // Start a listening socket and populate the DCI structure with
            // network information
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0);
            _listener = new StreamSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _listener.Bind(ipep);

            RendezvousData rd = new RendezvousData();
            Port = (ushort) ((IPEndPoint) _listener.LocalEndPoint).Port;
            _listener.Listen(1);
            _listener.BeginAccept(new AsyncCallback(AcceptConnection), rd);

            // Send the "send file" request on SNAC(04,06):02
            parent.Messages.RequestDirectConnectionInvite(this);
        }
Beispiel #2
0
 /// <summary>
 /// Connects directly to an IP address
 /// </summary>
 /// <param name="address">The IP address to which to connect</param>
 private void ConnectToIPAddress(IPAddress address)
 {
     IPEndPoint ipep = new IPEndPoint(address, GetPortForInitialConnection());
     StreamType sttp = destinationSsl ? StreamType.SslStream : StreamType.NetworkStream;
     socket = new StreamSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, sttp);
     try
     {
         socket.BeginConnect(ipep, EndConnectToIPAddress, null);
     }
     catch(Exception sockex)
     {
         OnConnectionFailed("Cannot connect to server: {0}", sockex);
     }
 }