public static Transport Create(AddressEntry entry) { switch (entry.Method) { case "tcp": { Transport transport = new SocketTransport(); transport.Open(entry); return(transport); } #if !PORTABLE case "unix": { //Transport transport = new UnixMonoTransport (); Transport transport = new UnixNativeTransport(); transport.Open(entry); return(transport); } #endif #if ENABLE_PIPES case "win": { Transport transport = new PipeTransport(); transport.Open(entry); return(transport); } #endif default: throw new NotSupportedException("Transport method \"" + entry.Method + "\" not supported"); } }
//int nIters = 0; public void GetData() { //nIters++; //Console.WriteLine ("nIters: " + nIters); if (msgRdr == null) { msgRdr = ReadMessageReal2(); } /* * { * System.Net.Sockets.NetworkStream nns = ns as System.Net.Sockets.NetworkStream; * SocketTransport st = this as SocketTransport; * if (!nns.DataAvailable) * return null; * } */ SocketTransport st = this as SocketTransport; //int nread = ns.Read (mmbuf, mmpos, 16); int avail = st.socket.Available; if (mmneeded == 0) { throw new Exception(); } //if (avail < mmneeded) // System.Threading.Thread.Sleep (10); if (avail == 0) { return; } avail = Math.Min(avail, mmneeded); int nread = st.socket.Receive(mmbuf, mmpos, avail, System.Net.Sockets.SocketFlags.None); mmpos += nread; mmneeded -= nread; if (!msgRdr.MoveNext()) { throw new Exception(); } MsgState state = msgRdr.Current; if (state != MsgState.Done) { return; } mmpos = 0; mmneeded = 16; msgRdr = null; }
public static Transport Create (AddressEntry entry) { switch (entry.Method) { case "tcp": { Transport transport = new SocketTransport (); transport.Open (entry); return transport; } #if !PORTABLE case "unix": { //Transport transport = new UnixMonoTransport (); Transport transport = new UnixNativeTransport (); transport.Open (entry); return transport; } #endif default: throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported"); } }