I'm working on an application that would be slated as legacy code. Its been ported from using OpenTransport to Cfosckets. The network side of things runs in a cfrunloop and accepts on a callback then receives data on a callback. Inside this receive callback function are the calls to rest of the software. The software is single threaded and this work fairly well as the routines won't get called until all data is received. Also inside this function once the routines are done it sends the result data back out to the socket descriptor using cfsocketsenddata. This code seems to work very fast but as more traffic comes in… lets say 40 requests per second it seems like its backing up. The time it takes for the receive data function to complete is about 2ms to 12ms depending on the complexity of the data returned. Should I be sending my data back to the end user via the receive data callback function or is that costly. I'm starting to wonder if they are on a slow connection its taking a long time to finish and its holding up other connections. I'm using these socket flags right now.
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes));
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
Here is the structure of it all.
Void setupconnection()
{
Setupstuff here and register accept callback
}
Void acceptcallback()
{
Make sure the connection works set up context for data register receive data callback
}
Void receive data()
{
Bring in data
Make calls to answer questions for end user
Pack up answers
Send answers via cfsocketsenddata
Close connection and release response data
}
Its stumping me a bit as this code seems to really work fast but I still don't have full understanding of CoreFoundations. There seems to be a bit of a tipping point when many people are connected at once I'd say at least around 60 connections. Any info would be great. Thanks.
~Jeremy