private void startListening()
{
NetworkStream stream = clientList.GetStream();
Byte[] bytes = new Byte[256];
int k;
byte[] rdata = null;
int totalLength = 0;
try
{
while (clientList.Connected)
{
while ((k = stream.Read(bytes, 0, bytes.Length)) != 0)
{
totalLength = k;
encryptedData = new byte[totalLength];
rdata = new byte[(7 * totalLength) / 8];
Array.Copy(bytes, 0, encryptedData, 0, totalLength);
totalLength = decodeReceivedGsmData(encryptedData, totalLength, rdata);
for (int i = 0; i < totalLength; i++)
Console.Write(rdata[i] + " ");
Console.WriteLine();
if ((rdata[0] < 200) && (rdata[0] >= 32))
{
receiverRC.dataFromGsm = new byte[totalLength];
for (int i = 0; i < totalLength; i++)
{
receiverRC.dataFromGsm[i] = rdata[i];
}
receiverRC.needToSendMsgFromGsmToOtherProjects = true;
}
else if (rdata[0] >= 200)
{
receiverMC.dataFromGsm = new byte[totalLength];
for (int i = 0; i < totalLength; i++)
{
receiverMC.dataFromGsm[i] = rdata[i];
}
receiverMC.needToSendMsgFromGsmToOtherProjects = true;
}
}
}
}
catch (Exception ex)
{
}
}
private byte[] Combine(byte[] a, int length1, byte[] b, int length2)
{
byte[] c = new byte[a.Length + b.Length];
System.Buffer.BlockCopy(a, 0, c, 0, length1);
System.Buffer.BlockCopy(b, 0, c, length1, length2);
return c;
}
problem record
Gsm kapatildi
Exception : System.Threading.ThreadAbortException: Thread was being aborted.
at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle, Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at CardControlProject.ListenerGSM.startListening() in C:\Users\SONY\Desktop\Programs in11 C#\Card Control\SerialPortListener\ListenerGSM.cs:line 108
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in CardControlProject.exe
An exception of type 'System.Threading.ThreadAbortException' occurred in CardControlProject.exe but was not handled in user code
A first chance exception of type 'System.IO.IOException' occurred in System.dll
Exception : System.IO.IOException: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall. ---> System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at CardControlProject.ListenerGSM.startListening() in C:\Users\SONY\Desktop\Programs in11 C#\Card Control\SerialPortListener\ListenerGSM.cs:line 108
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in System.dll
Exception : System.Threading.ThreadAbortException: Thread was being aborted.
at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle, Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at CardControlProject.ListenerGSM.startListening() in C:\Users\SONY\Desktop\Programs in11 C#\Card Control\SerialPortListener\ListenerGSM.cs:line 108
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in CardControlProject.exe
An exception of type 'System.Threading.ThreadAbortException' occurred in CardControlProject.exe but was not handled in user code