mirror of
https://github.com/reactos/reactosdbg.git
synced 2024-11-27 13:40:26 +00:00
6030ecd415
locals and stack trace at the place where reactos is stopped. svn path=/trunk/tools/reactosdbg/; revision=759
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Net.Sockets;
|
|
|
|
namespace Gdb
|
|
{
|
|
public class SocketPipe : Pipe
|
|
{
|
|
Socket mSocket;
|
|
byte []mBuf = new byte[4096];
|
|
IAsyncResult mResult;
|
|
|
|
public event PipeReceiveEventHandler PipeReceiveEvent;
|
|
public bool Write(string output)
|
|
{
|
|
byte []outbuf = UTF8Encoding.UTF8.GetBytes(output);
|
|
int off = 0, res;
|
|
do
|
|
{
|
|
res = mSocket.Send(outbuf, off, outbuf.Length - off, SocketFlags.None);
|
|
if (res > 0)
|
|
off += res;
|
|
}
|
|
while (off < outbuf.Length && res != -1);
|
|
return off == outbuf.Length;
|
|
}
|
|
|
|
public void TriggerReadable(IAsyncResult result)
|
|
{
|
|
int bytes = mSocket.EndReceive(mResult);
|
|
string datastr = UTF8Encoding.UTF8.GetString(mBuf, 0, bytes);
|
|
if (PipeReceiveEvent != null)
|
|
PipeReceiveEvent(this, new PipeReceiveEventArgs(datastr));
|
|
mResult = mSocket.BeginReceive
|
|
(mBuf, 0, mBuf.Length, SocketFlags.None, TriggerReadable, this);
|
|
}
|
|
|
|
public SocketPipe(Socket socket)
|
|
{
|
|
mSocket = socket;
|
|
mResult = mSocket.BeginReceive
|
|
(mBuf, 0, mBuf.Length, SocketFlags.None, TriggerReadable, this);
|
|
}
|
|
}
|
|
}
|