コード例 #1
0
ファイル: Socket.cs プロジェクト: rvlietstra/ROS.NET
 public Socket(ns.AddressFamily addressFamily, ns.SocketType socketType, ns.ProtocolType protocolType)
     : base(addressFamily, socketType, protocolType)
 {
     lock (_socklist)
     {
         _socklist.Add(FD, this);
     }
     //EDB.WriteLine("Making socket w/ FD=" + FD);
 }
コード例 #2
0
ファイル: Socket.cs プロジェクト: rvlietstra/ROS.NET
 public Socket(ns.SocketInformation socketInformation)
     : base(socketInformation)
 {
     lock (_socklist)
     {
         _socklist.Add(FD, this);
     }
     //EDB.WriteLine("Making socket w/ FD=" + FD);
 }
コード例 #3
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public int Send(byte[] arr, int offset, int size, ns.SocketFlags f, out ns.SocketError er)
 {
     return realsocket.Send(arr, offset, size, f, out er);
 }
コード例 #4
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public int Receive(byte[] arr, int offset, int size, ns.SocketFlags f)
 {
     return realsocket.Receive(arr,offset,size,f);
 }
コード例 #5
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public int IOControl(ns.IOControlCode code, byte[] inval, byte[] outval)
 {
     return realsocket.IOControl(code, inval, outval);
 }
コード例 #6
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public byte[] GetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n, int optionlength)
 {
     return realsocket.GetSocketOption(lvl, n, optionlength);
 }
コード例 #7
0
ファイル: torrent.cs プロジェクト: peteward44/torrent.net
		// Called by the Session class for peers connecting through the server, adds it to a list which can then be added when
		// ProcessWaitingData() is called so we keep it on one thread
		internal void AddPeer( Sockets.Socket socket, Sockets.NetworkStream netStream, PeerInformation peerInformation )
		{
			lock ( mWaitingPeers.SyncRoot )
			{
				mWaitingPeers.Add( new object[] { socket, netStream, peerInformation } );
			}
		}
コード例 #8
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public Socket(ns.AddressFamily addressFamily, ns.SocketType socketType, ns.ProtocolType protocolType)
     : this(new ns.Socket(addressFamily, socketType, protocolType))
 {
     //EDB.WriteLine("Making socket w/ FD=" + FD);
 }
コード例 #9
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public bool SafePoll(int timeout, ns.SelectMode sm)
 {
     bool res = false;
     try
     {
         if (!disposed)
             res = realsocket.Poll(timeout, sm);
     }
     catch (ns.SocketException e)
     {
         EDB.WriteLine(e);
         res = !disposed && sm == ns.SelectMode.SelectError;
     }
     return res;
 }
コード例 #10
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public bool ConnectAsync(ns.SocketAsyncEventArgs e)
 {
     attemptedConnectionEndpoint = e.RemoteEndPoint.ToString();
     return realsocket.ConnectAsync(e);
 }
コード例 #11
0
ファイル: Socket.cs プロジェクト: rvlietstra/ROS.NET
 public Socket(ns.Socket sock)
     : this(sock.DuplicateAndClose(Process.GetCurrentProcess().Id))
 {
 }
コード例 #12
0
ファイル: Socket.cs プロジェクト: rvlietstra/ROS.NET
 public bool SafePoll(int timeout, ns.SelectMode sm)
 {
     lock (this)
     {
         bool res = false;
         try
         {
             res = !disposed && Poll(timeout, sm);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             res = !disposed && sm == ns.SelectMode.SelectError;
         }
         return res;
     }
 }
コード例 #13
0
ファイル: torrent.cs プロジェクト: peteward44/torrent.net
		// Called by the Session class for peers connecting through the server and in StartPeerConnectionThread() method for peers
		// connected to directly
		private void AddPeerPrivate(Sockets.Socket socket, Sockets.NetworkStream netStream, PeerInformation peerInformation)
		{
			try
			{
				if ( Config.ActiveConfig.MaxPeersConnected < this.mPeers.Count )
				{
					socket.Close();
					return;
				}

				bool connect = true;

				if (Config.ActiveConfig.OnlyOneConnectionFromEachIP)
				{
					foreach ( Peer connectedPeer in this.mPeers )
					{
						if (connectedPeer.Information.IP.Equals(peerInformation.IP))
						{
							connect = false;
							break;
						}
					}
				}

				if (!connect)
				{
					socket.Close();
					return;
				}

				if (!this.downloadFile.Bitfield.AllFalse)
					PeerProtocol.SendBitfieldMessage(netStream, this.downloadFile);

				Peer peer = new Peer(this.infofile, this.downloadFile, socket, netStream, peerInformation);
				peer.Disconnected += new PeerDisconnectedCallback(peer_Disconnected);

				Config.LogDebugMessage("Connection accepted from: " + peer.ToString());

				// add to download and upload manager
				this.mDownloadStrategy.HookPeerEvents(peer);
				this.uploadManager.AddPeer(peer);
				this.peerManager.AddPeer(peer);

				if (this.PeerConnected != null)
					this.PeerConnected(this, peer, true);

				this.mPeers.Add( peer );
			}
			catch ( System.Exception e )
			{
				Config.LogException( e );
			}
		}
コード例 #14
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public void SetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n, object optionvalue)
 {
     realsocket.SetSocketOption(lvl, n, optionvalue);
 }
コード例 #15
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public bool AcceptAsync(ns.SocketAsyncEventArgs a)
 {
     return realsocket.AcceptAsync(a);
 }
コード例 #16
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public void Shutdown(ns.SocketShutdown sd)
 {
     realsocket.Shutdown(sd);
 }
コード例 #17
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public object GetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n)
 {
     return realsocket.GetSocketOption(lvl, n);
 }
コード例 #18
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public Socket(ns.Socket sock)
 {
     realsocket = sock;
     disposed = false;
 }
コード例 #19
0
ファイル: Socket.cs プロジェクト: uml-robotics/ROS.NET
 public void GetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n, byte[] optionvalue)
 {
     realsocket.GetSocketOption(lvl, n, optionvalue);
 }
コード例 #20
0
ファイル: peer.cs プロジェクト: peteward44/torrent.net
		public Peer(MetainfoFile infofile, DownloadFile downloadFile,
			Sockets.Socket socket, Sockets.NetworkStream netStream, PeerInformation peerInformation)
		{
			this.infofile = infofile;
			this.downloadFile = downloadFile;
			this.socket = socket;
			this.netStream = netStream;
			this.peerInformation = peerInformation;

			this.piecesDownloaded = new BitField(this.infofile.PieceCount);
			this.peerProtocol.UpThrottle.Start();
			this.peerProtocol.DownThrottle.Start();
		}
コード例 #21
0
ファイル: SocketClient.cs プロジェクト: andychops/Libraries
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="bufferSize"></param>
 /// <param name="socket"></param>
 public SocketState(int bufferSize, Sockets.Socket socket)
 {
     _BufferSize = bufferSize;
     _WorkBuffer = new byte[bufferSize];
     _WorkSocket = socket;
     _WorkStringBuilder = new StringBuilder();
 }