|
-
February 3rd, 2008, 10:55 AM
#1
Failed Socket.Send causes device to slow down
I have problems with a program for SmartPhone 2003 using .NET CF 1.0. I don't know if this is a C# problem or a SmartPhone problem.
Every 30 seconds the program sends a short UDP packet via GPRS, using the code below. If the packet is sent succesfully, SendPacket returns true. If the phone has no usable data connection, SendPacket will immediately return false (which is good), but unfortunately the phone menus (all menus, not just in this program) get very unresponsive after only a few failed attempts. There is no increased memory usage so I am assuming heavy CPU load.
I am wondering if I need to do some manual cleanup after a failed attempt. I have until now assumed that the packet will just "disappear" when the .Send method throws an exception, but now I think that something is left behind.
This is the socket:
Code:
private Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Code:
socket.Connect(new IPEndPoint(IPAddress.Parse(RemoteAddress), RemotePort));
This is the code for sending a packet:
Code:
public bool SendPacket(byte[] sendData)
{
try
{
socket.Send(sendData);
return true;
}
catch (Exception)
{
return false;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|