Difference between revisions of "Simple TCP pair"

From CRIU
Jump to navigation Jump to search
m (Categorize)
(collapse tcp.c text)
Line 3: Line 3:
 
== Compile and run simple TCP client and server ==
 
== Compile and run simple TCP client and server ==
 
The below program is a simple echo server and a client, that pings server with increasing numbers once a second. In this howto we will dump and restore the client part.
 
The below program is a simple echo server and a client, that pings server with increasing numbers once a second. In this howto we will dump and restore the client part.
 +
{| class="collapsible <includeonly>collapsed</includeonly> collapsed" border="0"
 +
|-
 +
! tcp-howto.c:
 +
|-
 +
|
 
<pre>
 
<pre>
 
#include <sys/socket.h>
 
#include <sys/socket.h>
Line 161: Line 166:
 
}
 
}
 
</pre>
 
</pre>
 +
|}
  
 
So compile it and run server
 
So compile it and run server

Revision as of 16:32, 12 April 2013

This page describes step-by-step how to play with TCP dumping and restoring.

Compile and run simple TCP client and server

The below program is a simple echo server and a client, that pings server with increasing numbers once a second. In this howto we will dump and restore the client part.

So compile it and run server

# ./tcp-howto <some-port>

and on another terminal (for better output readability) -- the client

# ./tcp-howto 127.0.0.1 <some-port>

Try to dump the client

Create a directory for images (img-dir/ below) and dump the client

# crtools dump --tree <tcp-howto-client-pid> --images-dir img-dir/ -v 4 -o dump.log --shell-job --tcp-established

The --tcp-established option is a must, since client have active TCP connection and we should explicitly inform crtools about it.

The --shell-job option is also required, as the client was launched from shell and uses shell's session and terminal.

Then restore the client

It's done like this

# crtools restore --tree <tcp-howto-client-pid> --images-dir img-dir/ -v 4 -o rst.log --shell-job --tcp-established

That's it. After this in the terminal you launched crtools from you should see the contunuing output of the tcp client.