03-14-2015
please read this, there is no message boundary in TCP. It is just like reading from a pipe and you receive whatever is available.
Please refer this example
10 More Discussions You Might Find Interesting
1. IP Networking
I am trying to connect via DBACCESS and Informix server to a server on a different computer. When I execute the connect command from dbaccess I get the following message,
Exec format error cannot bind a name to the port.
As far as I know the port is not being used by another client.
How... (1 Reply)
Discussion started by: lopez
1 Replies
2. IP Networking
Hi Eveyone,
I have A small problems maybe some one can help me. I'm running a small network at home with internet access. Two PC's have Win XP and one has Win98se. I have them all hook up on a SMC router. ALL windows firewall are off and and harddrive sharing is on. I am using DCHP network... (3 Replies)
Discussion started by: Peterh
3 Replies
3. Solaris
I am running a Java Client on Solaris 9 which communicates with the Server using TCP/IP.
The client transmits a FIN packet to server. The server sends a ACK, FIN enters LAST_ACK state and then waits for ACK from client. The client did not respond back leaving the server in LAST_ACK itself. Also... (0 Replies)
Discussion started by: diarun
0 Replies
4. Programming
There is a server and a client,when client send a message to server,server can send a reply to client. The status of server and client is ESTABLISHED.Then I halt the client,I find the server status is CLOSE_WAIT and the client status is FIN_WAIT_2. Many minutes passed,I find the the server status... (1 Reply)
Discussion started by: konvalo
1 Replies
5. Programming
Greetings!
I am attempting to write a *basic* network client in C. I have manage to create a socket but I have doubts as far as using AF_INET vs AF_UNIX.
At the present time, my client runs with AF_INET. Is AF_UNIX faster across hosts using the same OS flavor (Red Hat)? What is the difference... (1 Reply)
Discussion started by: Alan Christen
1 Replies
6. Red Hat
how the data from disk is loaded into memory and then it transfered to tcp/ip packet.
how i can find how many pages are loaded into memory by that process
what is the rate of context switch for that process. (5 Replies)
Discussion started by: amar20
5 Replies
7. Shell Programming and Scripting
how the data from disk is loaded into memory and then it supplied to tcp/ip packet.
how i can trace the no of pages loaded in memory by that process and rate of context switch for that process. (1 Reply)
Discussion started by: amar20
1 Replies
8. Programming
Hello @ all,
I hope you can give me some advice :b:
I will be following code for a tcp server and doStuff () function, the
clients treated. From some point, I have several identical
clients (zombies, I think), the same records in the database
write. Has anyone an explanation? What can I... (1 Reply)
Discussion started by: yumos
1 Replies
9. IP Networking
Hello all.
This is my first post and thank you for your forum.
Here is my question.
I have a simple setup at home and I was capturing some data with wireshark.
Data between a workstation and the web server, requesting a page.
Simple enough.
Now when I open wireshark, I apply the TCP... (4 Replies)
Discussion started by: squaresphere
4 Replies
10. UNIX for Advanced & Expert Users
Hi all.
I have a really really weird problem that I've been working on for days.
The problem manifested as users cannot connect to our web servers via SSH when they're using our wireless network. Here's where it gets weird:
- Clients from anywhere other than the wireless subnet can... (4 Replies)
Discussion started by: pileofrogs
4 Replies
LEARN ABOUT DEBIAN
test::tcp
Test::TCP(3pm) User Contributed Perl Documentation Test::TCP(3pm)
NAME
Test::TCP - testing TCP program
SYNOPSIS
use Test::TCP;
my $server = Test::TCP->new(
code => sub {
my $port = shift;
...
},
);
my $client = MyClient->new(host => '127.0.0.1', port => $server->port);
undef $server; # kill child process on DESTROY
Using memcached:
use Test::TCP;
my $memcached = Test::TCP->new(
code => sub {
my $port = shift;
exec $bin, '-p' => $port;
die "cannot execute $bin: $!";
},
);
my $memd = Cache::Memcached->new({servers => ['127.0.0.1:' . $memcached->port]});
...
And functional interface is available:
use Test::TCP;
test_tcp(
client => sub {
my ($port, $server_pid) = @_;
# send request to the server
},
server => sub {
my $port = shift;
# run server
},
);
DESCRIPTION
Test::TCP is test utilities for TCP/IP programs.
METHODS
empty_port
my $port = empty_port();
Get the available port number, you can use.
test_tcp
Functional interface.
test_tcp(
client => sub {
my $port = shift;
# send request to the server
},
server => sub {
my $port = shift;
# run server
},
# optional
port => 8080
);
wait_port
wait_port(8080);
Waits for a particular port is available for connect.
OO-ish interface
my $server = Test::TCP->new(%args);
Create new instance of Test::TCP.
Arguments are following:
$args{auto_start}: Boolean
Call "$server->start()" after create instance.
Default: true
$args{code}: CodeRef
The callback function. Argument for callback function is: "$code->($pid)".
This parameter is required.
$server->start()
Start the server process. Normally, you don't need to call this method.
$server->stop()
Stop the server process.
my $pid = $server->pid();
Get the pid of child process.
my $port = $server->port();
Get the port number of child process.
FAQ
How to invoke two servers?
You can call test_tcp() twice!
test_tcp(
client => sub {
my $port1 = shift;
test_tcp(
client => sub {
my $port2 = shift;
# some client code here
},
server => sub {
my $port2 = shift;
# some server2 code here
},
);
},
server => sub {
my $port1 = shift;
# some server1 code here
},
);
Or use OO-ish interface instead.
my $server1 = Test::TCP->new(code => sub {
my $port1 = shift;
...
});
my $server2 = Test::TCP->new(code => sub {
my $port2 = shift;
...
});
# your client code here.
...
How do you test server program written in other languages like memcached?
You can use "exec()" in child process.
use strict;
use warnings;
use utf8;
use Test::More;
use Test::TCP 1.08;
use File::Which;
my $bin = scalar which 'memcached';
plan skip_all => 'memcached binary is not found' unless defined $bin;
my $memcached = Test::TCP->new(
code => sub {
my $port = shift;
exec $bin, '-p' => $port;
die "cannot execute $bin: $!";
},
);
use Cache::Memcached;
my $memd = Cache::Memcached->new({servers => ['127.0.0.1:' . $memcached->port]});
$memd->set(foo => 'bar');
is $memd->get('foo'), 'bar';
done_testing;
AUTHOR
Tokuhiro Matsuno <tokuhirom@gmail.com>
THANKS TO
kazuhooku
dragon3
charsbar
Tatsuhiko Miyagawa
lestrrat
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-02-01 Test::TCP(3pm)