c++ - How to test connect timeout on RHEL c/cpp application -


I have an application that talks HTTP over the server I have written a code to control the connect timeout (The server will wait before the reply). But I'm having difficulty creating a test case to test my connect timeout code. could you help me please.

In fact, TCP sends a TCP synchronized packet to host A in host B in a handshake

Host B receives an SN of the S

Host B A SYNchronize - receives a receipt

Host A gets the SYN-ACK of B

Host A sends a knowledge

Host B receives AC TCP socket connection is established.

In my application, if the server does not complete TCP handheld in X second, then the application goes to the next server. But to test this code, I need a server stub, which is probably the client SYN will accept the packet from but the client will not set the SYN + ACK packet. Thus the client is waiting for the server to respond.

Can you please help me create a small server stub that will listen to the particular port but will not complete the handshake.

You have mentioned RHEL, I think that to help you check it Iptables . For example, you can call:

  iptables -i INPUT -s hostb -d hosta -p tcp --dport $ port --tcp-flags SYN, ACK SYN, ACK -J Dropping   

Before the test is running (or perhaps probably?) And it is said to remove the equivalent of Mail-X, it seems that the simplest way to join halfway The way.

Drop all SYN + ACK (warning, Will break new SSH connections):

  iptables -i INPUT -p tcp - -tcp-flags SYN, ACK SIN, ACK-J drop   

Leave all or 10-10.22.34:

  iptables -i INPUT -s 10.10.22.34 -J drop IPTable- I Output-D 10.10.22.34-J Drop Individuals I use the most specific match, which you can probably avoid distant distances or something else at the same time Can write for 

You can get the embroidery and use the -m owner match to apply this rule only to packet to run this test from the UK / .

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -