Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / IO::Socket.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "IO::Socket 3"
132.TH IO::Socket 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134IO::Socket \- Object interface to socket communications
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use IO::Socket;
139.Ve
140.SH "DESCRIPTION"
141.IX Header "DESCRIPTION"
142\&\f(CW\*(C`IO::Socket\*(C'\fR provides an object interface to creating and using sockets. It
143is built upon the IO::Handle interface and inherits all the methods defined
144by IO::Handle.
145.PP
146\&\f(CW\*(C`IO::Socket\*(C'\fR only defines methods for those operations which are common to all
147types of socket. Operations which are specified to a socket in a particular
148domain have methods defined in sub classes of \f(CW\*(C`IO::Socket\*(C'\fR
149.PP
150\&\f(CW\*(C`IO::Socket\*(C'\fR will export all functions (and constants) defined by Socket.
151.SH "CONSTRUCTOR"
152.IX Header "CONSTRUCTOR"
153.IP "new ( [\s-1ARGS\s0] )" 4
154.IX Item "new ( [ARGS] )"
155Creates an \f(CW\*(C`IO::Socket\*(C'\fR, which is a reference to a
156newly created symbol (see the \f(CW\*(C`Symbol\*(C'\fR package). \f(CW\*(C`new\*(C'\fR
157optionally takes arguments, these arguments are in key-value pairs.
158\&\f(CW\*(C`new\*(C'\fR only looks for one key \f(CW\*(C`Domain\*(C'\fR which tells new which domain
159the socket will be in. All other arguments will be passed to the
160configuration method of the package for that domain, See below.
161.Sp
162.Vb 1
163\& NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
164.Ve
165.Sp
166As of \s-1VERSION\s0 1.18 all IO::Socket objects have autoflush turned on
167by default. This was not the case with earlier releases.
168.Sp
169.Vb 1
170\& NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
171.Ve
172.SH "METHODS"
173.IX Header "METHODS"
174See perlfunc for complete descriptions of each of the following
175supported \f(CW\*(C`IO::Socket\*(C'\fR methods, which are just front ends for the
176corresponding built-in functions:
177.PP
178.Vb 10
179\& socket
180\& socketpair
181\& bind
182\& listen
183\& accept
184\& send
185\& recv
186\& peername (getpeername)
187\& sockname (getsockname)
188\& shutdown
189.Ve
190.PP
191Some methods take slightly different arguments to those defined in perlfunc
192in attempt to make the interface more flexible. These are
193.IP "accept([\s-1PKG\s0])" 4
194.IX Item "accept([PKG])"
195perform the system call \f(CW\*(C`accept\*(C'\fR on the socket and return a new
196object. The new object will be created in the same class as the listen
197socket, unless \f(CW\*(C`PKG\*(C'\fR is specified. This object can be used to
198communicate with the client that was trying to connect.
199.Sp
200In a scalar context the new socket is returned, or undef upon
201failure. In a list context a two-element array is returned containing
202the new socket and the peer address; the list will be empty upon
203failure.
204.Sp
205The timeout in the [\s-1PKG\s0] can be specified as zero to effect a \*(L"poll\*(R",
206but you shouldn't do that because a new IO::Select object will be
207created behind the scenes just to do the single poll. This is
208horrendously inefficient. Use rather true \fIselect()\fR with a zero
209timeout on the handle, or non-blocking \s-1IO\s0.
210.IP "socketpair(\s-1DOMAIN\s0, \s-1TYPE\s0, \s-1PROTOCOL\s0)" 4
211.IX Item "socketpair(DOMAIN, TYPE, PROTOCOL)"
212Call \f(CW\*(C`socketpair\*(C'\fR and return a list of two sockets created, or an
213empty list on failure.
214.PP
215Additional methods that are provided are:
216.IP "atmark" 4
217.IX Item "atmark"
218True if the socket is currently positioned at the urgent data mark,
219false otherwise.
220.Sp
221.Vb 1
222\& use IO::Socket;
223.Ve
224.Sp
225.Vb 2
226\& my $sock = IO::Socket::INET->new('some_server');
227\& $sock->read(1024,$data) until $sock->atmark;
228.Ve
229.Sp
230Note: this is a reasonably new addition to the family of socket
231functions, so all systems may not support this yet. If it is
232unsupported by the system, an attempt to use this method will
233abort the program.
234.Sp
235The \fIatmark()\fR functionality is also exportable as \fIsockatmark()\fR function:
236.Sp
237.Vb 1
238\& use IO::Socket 'sockatmark';
239.Ve
240.Sp
241This allows for a more traditional use of \fIsockatmark()\fR as a procedural
242socket function. If your system does not support \fIsockatmark()\fR, the
243\&\f(CW\*(C`use\*(C'\fR declaration will fail at compile time.
244.IP "connected" 4
245.IX Item "connected"
246If the socket is in a connected state the the peer address is returned.
247If the socket is not in a connected state then undef will be returned.
248.IP "protocol" 4
249.IX Item "protocol"
250Returns the numerical number for the protocol being used on the socket, if
251known. If the protocol is unknown, as with an \s-1AF_UNIX\s0 socket, zero
252is returned.
253.IP "sockdomain" 4
254.IX Item "sockdomain"
255Returns the numerical number for the socket domain type. For example, for
256an \s-1AF_INET\s0 socket the value of &AF_INET will be returned.
257.IP "sockopt(\s-1OPT\s0 [, \s-1VAL\s0])" 4
258.IX Item "sockopt(OPT [, VAL])"
259Unified method to both set and get options in the \s-1SOL_SOCKET\s0 level. If called
260with one argument then getsockopt is called, otherwise setsockopt is called.
261.IP "socktype" 4
262.IX Item "socktype"
263Returns the numerical number for the socket type. For example, for
264a \s-1SOCK_STREAM\s0 socket the value of &SOCK_STREAM will be returned.
265.IP "timeout([\s-1VAL\s0])" 4
266.IX Item "timeout([VAL])"
267Set or get the timeout value associated with this socket. If called without
268any arguments then the current setting is returned. If called with an argument
269the current setting is changed and the previous value returned.
270.SH "SEE ALSO"
271.IX Header "SEE ALSO"
272Socket, IO::Handle, IO::Socket::INET, IO::Socket::UNIX
273.SH "AUTHOR"
274.IX Header "AUTHOR"
275Graham Barr. \fIatmark()\fR by Lincoln Stein. Currently maintained by the
276Perl Porters. Please report all bugs to <perl5\-porters@perl.org>.
277.SH "COPYRIGHT"
278.IX Header "COPYRIGHT"
279Copyright (c) 1997\-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
280This program is free software; you can redistribute it and/or
281modify it under the same terms as Perl itself.
282.PP
283The \fIatmark()\fR implementation: Copyright 2001, Lincoln Stein <lstein@cshl.org>.
284This module is distributed under the same terms as Perl itself.
285Feel free to use, modify and redistribute it as long as you retain
286the correct attribution.