343210
Q1: 我之前是在C#的client端对server端进行socket发送请求和接受数据,语句如下
socket.Send(frameBuffer, bufferLength, ScoketFlasg.None);
socket.Receive(framBuffer, numBytesRead, HEADER_length, SocketFlags.None);
那么现在在node下面怎么实现同样的效果呢?
Q2: JavaScript怎么将object转化成array? 比如:我有下面的一个class以及它的实例,该怎么表达
public abstract class Command
{
//
// Data members
//
private DeviceBase m_device;
private readonly byte m_code;
private byte m_error;
private Exception m_transporException;
private ManualResetEvent m_completeEvent;
//
// Constructor
//
public Command(DeviceBase device, byte code, ManualResetEvent completeEvent)
{
m_device = device;
m_code = code;
m_completeEvent = completeEvent;
if (m_completeEvent != null)
{
m_completeEvent.Reset();
}
m_error = 0;
m_transporException = null;
}
//
// Properties
//
public DeviceBase HostDevice
{
get
{
return m_device;
}
}
public byte CommandCode
{
get
{
return m_code;
}
}
public byte ErrorCode
{
get
{
return m_error;
}
protected set
{
m_error = value;
}
}
public Exception TransportException
{
get
{
return m_transporException;
}
internal set
{
m_transporException = value;
}
}
public EventWaitHandle CompleteEvent
{
get
{
return m_completeEvent;
}
}
}