Debian Codegraph @

examples/HOW_TO_USE

raw
1 Server side (who you are sending your request to)
2
3
4 use Server;
5
6 $server = Server->new(Server => name_of_host_to_bind_too, Port => port_number,
7 Queue => size_of_queue, SKey => 'shaReDSEcrET');
8
9
10 LOOP:
11 while ($ready_to_read = $server->accept()) { # wait for next connection
12 @info = $server->recv();
13 # @info now contains all of the data sent from the client
14 # already de-crypted
15 # to send info back to the client
16 $server->send("information", "to send", "back", "to" "client");
17 $server->close();
18 }
19
20 additional notes:
21
22 name_of_host_to_bind_too is usually the dns name assigned to the local box or
23 ip address
24
25 port_number for port's under 1024 you must be root to open
26
27 size_of_queue is the amount of backlog before a requested connection is rejected
28
29
30
31 Client Side (who you are sending your request from)
32
33 use Client;
34
35 $client = Client->new(Server => name_of_server_to_connect_to, Port => port_number,
36 SKey => 'shaReDSEcrET');
37
38 $client->send("information", "to", "send", "to" "the server");
39 @response = $client->recv();
40
41 print "response = @response\n";
42
43
44 additional notes:
45 the Client module closes the connection after doing a recv. So to have
46 more than one exchange you need to issue a Client->new for each pair, or
47 you can modify the Client->recv code
48 } else {
49 close ($self->{'Socket'}); # remove this line
50 return @response;
51 }
52
53 if you modify the code you must close the socket yourself somewhere else
54 close ($client->{'Socket'});