I m having Server modules which keep full time connections with other parties. And I m maintaining a echo message to keep the connection live each communication line. And I m sending/receiving messages from/to other party depending on the messages having in each server to/from.
But I notice that in sometimes I have delayed reading the request from the other party as per my Log time. But in the Wireshark logs Machine had received the message from the other party just after they write to me. ( Ex: Wireshark had logged the message after 6 mins later as per the Server logs)
And also I noticed that some messages going to other party has properly write() but as per the logs, no TCP packets are logged in the TCP dump( Wireshark Logs).
I m using standard read(), write() to read and write the messages to/from....
Since I m getting this error in Linux (RH) I change the OS to AIX, but the problem is still the same.
I m using the server port as 2030, 2031, 2032 and 2033 for my four identical server modules to connect other parties. And I also googled these ports and found that these ports are used in other services..
if(iSentSize != size)
//cout << "Error : Total data not properly written" << endl;
//FrameworkManager::printMsg(sTermId + ": Error : Total data not properly written");
PRINT_MESSAGE_NOTIME("ERROR", "Total data not properly written");
How does your class SocketServices initialise the socket? Does it just bind(), listen() and then accept() new connections?
Have you set any socket options (with setsockopt)?
You say you write onto the socket from multiple threads. Are these synchronised in any way? Does your Wireshark trace show outgoing packets when you experience these delays between the packet arriving and the read() completing?
SocketService class uses the normal socket(), bin(), accept() system calls for the sockets it creates.
And I dont have used any socket options.
And one more thing I want to clarify: In my application read() and the write() can be happened at the same time to the same socket connecting with the other party. But there I do not have used any syncronization method for this read and write.
And I want to know one more thing: Now Threads writing with other party are not sync. for writing in to the socket, and so do I need to make explicit mutex lock for the writing half of the socket..
Concurrent reading/writing should be fine, the TCP stack should deal with that. But if you have multiple threads writing to the same socket, you don't have to sync them, but you run the risk of your timestamps or sequence numbers being out of order on the stream.
What about the network traces and logs. What's happening in between the network trace showing the packet arriving and the "INFO -->External Gateway Message received" log message?