File: role-agent-objects.html

package info (click to toggle)
python-pysnmp2 2.0.9-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 476 kB
  • ctags: 471
  • sloc: python: 2,091; makefile: 8
file content (117 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<HTML>
<HEAD>
<TITLE>PySNMP: I/O engine: Single-session: Agent: Objects</TITLE>
</HEAD>

<BODY BGCOLOR="#ffffff" TEXT="#000000"
      LINK="#0000bb"  VLINK="#551a8b" ALINK="#ff0000">
<H3>
Objects of the <STRONG>role.agent</STRONG> class
</H3>

<P>
The instances of <STRONG>role.agent</STRONG> class have the following
methods:
</P>

<DL>
<DT><STRONG>receive_and_send</STRONG>(<STRONG>callback</STRONG>)</DT>
<DD>
<P>
Wait for request from a client process or timeout (and raise NoRequest
exception) if no request arrived within <STRONG>agent.timeout</STRONG>
seconds. On data arrival, pass data item to the <STRONG>callback</STRONG>
function, to build a response, and send the response back to client process.
</P>
<P>
The <STRONG>callback</STRONG> function is invoked in the following fashion:
<STRONG>callback</STRONG>(<STRONG>req</STRONG>, <STRONG>src</STRONG>) where
<STRONG>req</STRONG> is the data item as sent by client (string) and
<STRONG>src</STRONG> is the endpoint of client connection (given in
<STRONG>socket</STRONG> module notation).
</P>
<P>
The callback function must return a tuple of (<STRONG>rsp</STRONG>, 
<STRONG>dst</STRONG>), where <STRONG>rsp</STRONG> (string) is the data item
to be replied back to client by address <STRONG>dst</STRONG> (given in
<STRONG>socket</STRONG> module notation) or by originating address
if <STRONG>dst</STRONG> is None. 
</P>
</DD>
</DL>

<DL>
<DT><STRONG>open</STRONG>()</DT>
<DD>
<P>
Create socket object and bind it to local interface(s) to be used for
communication with remote client processes.
</P>
<P>
Return socket object.
</P>
</DD>
</DL>

<DL>
<DT><STRONG>send</STRONG>(<STRONG>rsp</STRONG>, <STRONG>dst</STRONG>)</DT>
<DD>
<P>
Attempt to send response data <STRONG>rsp</STRONG> (string) to remote
client by either <STRONG>dst</STRONG> address (given in <STRONG>socket</STRONG>
module notation).
</P>
</DD>
</DL>

<DL>
<DT><STRONG>receive</STRONG>()</DT>
<DD>
<P>
Wait for and receive request data from a client process or timeout (and
raise NoRequest exception) if no request arrived within
<STRONG>agent.timeout</STRONG> seconds.
</P>
<P>
Return a tuple of (<STRONG>req</STRONG>, <STRONG>src</STRONG>) where
<STRONG>req</STRONG> (string) is a request data as sent by client and
<STRONG>src</STRONG> is the address of client endpoint (given in
<STRONG>socket</STRONG> module notation).
</P>
</DD>
</DL>

<DL>
<DT><STRONG>close</STRONG>()</DT>
<DD>
<P>
Terminate server and release all associated resources.
</P>
</DD>
</DL>

<P>
Objects of the <STRONG>role.agent</STRONG> class have the following public
instance variables:
</P>

<DL>
<DT><STRONG>timeout</STRONG></DT>
<DD>
<P>
Specify for how many seconds to wait for request to arrive from a client. The
<STRONG>timeout</STRONG> attribute is of floating point type.
</P>
<P>
The default is None what means to wait forever.
</DD>
</DL>

<HR>

<ADDRESS>
ilya@glas.net
</ADDRESS>

</BODY>
</HTML>