Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool done;
- void SendData(TcpClient tcp, byte[] data)
- {
- NetworkStream ns = tcp.GetStream();
- done = false;
- ns.BeginWrite(bytWriteBuffer, 0, data.Length, myWriteCallBack, ns);
- while (done == false) Thread.Sleep(10);
- }
- public void myWriteCallBack(IAsyncResult ar)
- {
- NetworkStream ns = (NetworkStream)ar.AsyncState;
- ns.EndWrite(ar);
- done = true;
- }
- void SendData(TcpClient tcp, byte[] data) {
- NetworkStream ns = tcp.GetStream();
- // BUG?: should bytWriteBuffer == data?
- IAsyncResult r = ns.BeginWrite(bytWriteBuffer, 0, data.Length, null, null);
- r.AsyncWaitHandle.WaitOne();
- ns.EndWrite(r);
- }
- ns.Flush()
Add Comment
Please, Sign In to add comment