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); }
public Socket(ns.SocketInformation socketInformation) : base(socketInformation) { lock (_socklist) { _socklist.Add(FD, this); } //EDB.WriteLine("Making socket w/ FD=" + FD); }
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); }
public int Receive(byte[] arr, int offset, int size, ns.SocketFlags f) { return realsocket.Receive(arr,offset,size,f); }
public int IOControl(ns.IOControlCode code, byte[] inval, byte[] outval) { return realsocket.IOControl(code, inval, outval); }
public byte[] GetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n, int optionlength) { return realsocket.GetSocketOption(lvl, n, optionlength); }
// 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 } ); } }
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); }
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; }
public bool ConnectAsync(ns.SocketAsyncEventArgs e) { attemptedConnectionEndpoint = e.RemoteEndPoint.ToString(); return realsocket.ConnectAsync(e); }
public Socket(ns.Socket sock) : this(sock.DuplicateAndClose(Process.GetCurrentProcess().Id)) { }
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; } }
// 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 ); } }
public void SetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n, object optionvalue) { realsocket.SetSocketOption(lvl, n, optionvalue); }
public bool AcceptAsync(ns.SocketAsyncEventArgs a) { return realsocket.AcceptAsync(a); }
public void Shutdown(ns.SocketShutdown sd) { realsocket.Shutdown(sd); }
public object GetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n) { return realsocket.GetSocketOption(lvl, n); }
public Socket(ns.Socket sock) { realsocket = sock; disposed = false; }
public void GetSocketOption(ns.SocketOptionLevel lvl, ns.SocketOptionName n, byte[] optionvalue) { realsocket.GetSocketOption(lvl, n, optionvalue); }
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(); }
/// <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(); }