// ================== Public Methods ================== public Socket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) { // We only support TCP streams if (addressFamily != AddressFamily.InterNetwork) { throw new SocketException(SocketErrors.WSAEAFNOSUPPORT); } if (socketType == SocketType.Stream && protocolType == ProtocolType.Tcp) { internalSocket = new TcpSocket(); return; } if (socketType == SocketType.Dgram && protocolType == ProtocolType.Udp) { internalSocket = new UdpSocket(); return; } throw new SocketException(SocketErrors.WSAEPROTONOSUPPORT); }
public Socket Accept() { InternalSocket s = internalSocket.Accept(); if (s != null) { return(new Socket(s)); } return(null); }
// ================== Private Methods ================== private Socket(InternalSocket internalSocket) { this.internalSocket = internalSocket; }