if( ptr != NULL )
{
delete ptr;
ptr = NULL;
}
should be changed to:
delete ptr;
ptr = NULL;
This is plainly wrong when talking optimizations as the "delete ptr" statement will most likely turn into a function call to the delete operator, which will at the bare minimum check that ptr is not null before looking into the memory heap data structures.
Today this problem is almost gone, most routers are now RFC 4787 compliant. Great fix for the problem and those who have older routers can now game in peace.
Check out this vid on Top Routers for Gaming 2011 at http://www.youtube.com/watch?v=kASW1o4hImE. Get some ideas then do some more research after, get the info straight and get it right the first time.
You have about 30 minutes, maybe less than that to produce the program. That being said, I am not even sure that I had a working program during the alloted time. and no, they do not pay you for your time like any interviews in any company that I know and IMO, this is the right thing to do.
I have considerably embellished the program once I decided that I would publish it on my website. With all the comments, and all the cool STL usages within the program, I would say that I spent a good evening to bring the program as it is now.
Never had any interview where I was asked to write a program. Did that take you long to create Olivier; if ever it did facebook paid your time? Just asking out of curiosity.
Thank you, you are right, the router with IOS Firewall is doing NAT/PAT on the single IP address of the outside T1 interface. So the Google servers will see all users with the same IP address and different TCP port numbers. I will take a look at this some more.
it seems to be different. In the scenario I am describing, the client TCP/IP stack do receive the server reply. It is the application that do not sees it because a RST is immediately following the reply and is received by the TCP/IP stack before the application has the chance to read the reply from the stack.
This is not the problem that you have because if it was, you would see the reply precedes the RST segment with Wireshark.
In your situation, if you were asking me my opinion, I would suspect your router to be a NAT device and gmail server must have an internal limit that makes it refuse a single IP address to initiate more than a certain number of connections to protect itself against spammers.
I see some avenues to solve the problem:
1. If possible, configure your router to have more than 1 public IP address on the external NIC and make the router NAT module load balance the connections among the available public IP addresses.
2. Here is what my DNS server returns me for gmail.com:
I think I am experiencing the problem you are referring to in this blog.
I should preface my comment by stating that I am not a software programmer, I am a network hardware person who sells, install and maintains Cisco network switches, routers and firewalls for small and medium businesses.
I am troubleshooting an intermittent problem for a client who has about 100 users on gmail. They experiencing intermittent periods where one or more users cannot access their gmail. All other internet traffic (web, etc.)is ok. Resetting the Cisco3825 router firewall on the T1 line clears the problem. I did not believe that this was really a router problem. All sessions are terminated when the router restarts which is probably why it clears.
I have some Wireshark captures from when users are experiencing problems. What I am seeing is an immediate TCP RST coming back from the Google gmail server after the successfull TCP 3 way session initiation for HTTPS. There are no HTTP codes coming back from the server. This repeats over and over.
Funny that you asked why in a TIME WAIT state, the time out period is not 2*MSL. Actually, if you look at the diagram of TCP finite state machine (12 states), the Timeout is indicated to be 2MSL (towards the bottom, right next to TIME WAIT state). (In my case, the state digram is in the back inside cover of Inside TCP/IP book by K Siyan).