Click here to Skip to main content
16,020,315 members

Comments by Yu-Long Fang (Top 5 by date)

Yu-Long Fang 5-Jan-18 6:24am View    
Hello, Ralf,

I have never used BaseForm too.
I will also study that then decide which is the better solution for my project. Thank you!

Eric
Yu-Long Fang 5-Jan-18 5:55am View    
Hello, OriginalGriff,

I think UserControls might be a good idea.
I have never used that before. I will try to figure that out. Thank you!

Eric
Yu-Long Fang 24-Feb-15 7:38am View    
I set the buffer as local not static and it works! Thank you!
Yu-Long Fang 24-Feb-15 5:53am View    
I modify code as following, but still with the same error!

bool goOn = true;
int recvd = 0;
byte[] temp_buf = new byte[1024];
int expected_read_len = ethernet_get_read_len(Cmp_TxData);

try {
bytesSent = mSocket.Send(Cmp_TxData);
}
catch {
return null;
}

while (goOn)
{
try
{
recvd = mSocket.Receive(response);
}
catch
{
//something bad happened (timeout, connection reset, etc). Deal with it
return null;
}

if (recvd > 0)
{
// do something with the bytes, e. g. pass them on to a List<byte> etc.
Array.Copy(response, 0, temp_buf, bytesRec, recvd);
bytesRec = bytesRec + recvd;

if (expected_read_len != 0) {
if (bytesRec == expected_read_len)
{
goOn = false;
// other side closed, do something useful with data received
acknowledge = new byte[bytesRec];
Array.Copy(response, 0, acknowledge, 0, bytesRec);
}
}
}
else
{
// other side closed, do something useful with data received
// It's the way that sockets work. 0 can only be received if the socket is down.
goOn = false;
acknowledge = new byte[bytesRec];
Array.Copy(response, 0, acknowledge, 0, bytesRec);
}
}
Yu-Long Fang 24-Feb-15 3:55am View    
I set it to public, but still with error. Thank you for your information anyway.