File: sockets-naming.texi

package info (click to toggle)
adasockets 1.8.8-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,464 kB
  • ctags: 172
  • sloc: sh: 9,967; ada: 1,689; ansic: 357; makefile: 256
file content (397 lines) | stat: -rw-r--r-- 9,882 bytes parent folder | download | duplicates (11)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397

The @code{Sockets.Naming} package contains types and helper functions
needed to manipulate Internet host names and addresses.

@deftypefn Sockets.Naming.Address type Address is record@*@w{  }H1, H2, H3, H4 : Address_Component;@*end record;
This type represents an IPv4 address with @code{H1} being the first
octet and @code{H4} the last one. For example, 137.194.161.2 is
represented by @code{H1=137, H2=194, H3=161, H4=2}.

@end deftypefn

@deftypefn Sockets.Naming.Address_Array type Address_Array is array (Positive range <>) of Address;
Helper type

@end deftypefn

@deftypefn Sockets.Naming.Address_Component type Address_Component is Natural range 0 .. 255;
Helper type

@end deftypefn

@deftypefn Sockets.Naming.Host_Entry type Host_Entry (N_Aliases, N_Addresses : Natural) is new Ada.Finalization.Controlled with record@*@w{  } Name : String_Access;@*@w{  } Aliases : String_Array (1 .. N_Aliases);@*@w{  } Addresses : Address_Array (1 .. N_Addresses);@* end record;
The @code{Host_Entry} type holds a set of names and IP addresses
associated with a host. Each host can have several IP address
as well as several aliases.

@end deftypefn

@deftypefn Sockets.Naming.String_Access type String_Access is access String;
Helper type

@end deftypefn

@deftypefn Sockets.Naming.String_Array type String_Array is array (Positive range <>) of String_Access;
Helper type

@end deftypefn

@menu
* Address_Of (function)::
                        Get the IP address of a host
* Any_Address (function)::
                        Special address representing any address on the local host
* Get_Peer_Addr (function)::
                        Retrieve IP address of remote host
* Get_Peer_Port (function)::
                        Retrieve port used by remote host
* Get_Sock_Addr (function)::
                        Retrieve IP address of local host
* Get_Sock_Port (function)::
                        Retrieve port used by local host
* Host_Name (function)::
                        Get the name of the current host
* Image (function)::    Make a string from an address
* Info_Of_Name_Or_IP (function)::
                        Get addresses and names of a host
* Is_IP_Address (function)::
                        Check if given string is a valid IP address
* Name_Of (function)::  Official name of the host
* Value (function)::    Transform a string into an address
@end menu

@node Address_Of (function)
@unnumberedsubsec Address_Of (function)

@table @sc
@item Purpose
Get the IP address of a host
@item Prototype
@deftypefn Sockets.Naming.Address_Of function Address_Of (@w{@var{Something} : String})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Address_Of

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab Host name or IP address
@end multitable

@item Return value
IPv4 address


@item Exceptions
@multitable {XXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @code{Naming_Error} @tab No information available for this name or address@exindex Naming_Error
@end multitable





@item See also
@ref{Name_Of (function)}.

@end table

@node Any_Address (function)
@unnumberedsubsec Any_Address (function)

@table @sc
@item Purpose
Special address representing any address on the local host
@item Prototype
@deftypefn Sockets.Naming.Any_Address function Any_Address
@end deftypefn
@fnindex Sockets.Naming.Any_Address

@item Return value
Equivalent to @code{INADDR_ANY} in the C programming language




@end table

@node Get_Peer_Addr (function)
@unnumberedsubsec Get_Peer_Addr (function)

@table @sc
@item Purpose
Retrieve IP address of remote host
@item Prototype
@deftypefn Sockets.Naming.Get_Peer_Addr function Get_Peer_Addr (@w{@var{Socket} : Socket_FD})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Get_Peer_Addr

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Peer address




@item See also
@ref{Get_Peer_Port (function)},@*@ref{Get_Sock_Addr (function)}.

@end table

@node Get_Peer_Port (function)
@unnumberedsubsec Get_Peer_Port (function)

@table @sc
@item Purpose
Retrieve port used by remote host
@item Prototype
@deftypefn Sockets.Naming.Get_Peer_Port function Get_Peer_Port (@w{@var{Socket} : Socket_FD})@*@w{return Positive;}
@end deftypefn
@fnindex Sockets.Naming.Get_Peer_Port

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Port used on the remote host




@item See also
@ref{Get_Sock_Port (function)},@*@ref{Get_Peer_Addr (function)}.

@end table

@node Get_Sock_Addr (function)
@unnumberedsubsec Get_Sock_Addr (function)

@table @sc
@item Purpose
Retrieve IP address of local host
@item Prototype
@deftypefn Sockets.Naming.Get_Sock_Addr function Get_Sock_Addr (@w{@var{Socket} : Socket_FD})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Get_Sock_Addr

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Address of local interface used




@item See also
@ref{Get_Sock_Port (function)},@*@ref{Get_Peer_Addr (function)}.

@end table

@node Get_Sock_Port (function)
@unnumberedsubsec Get_Sock_Port (function)

@table @sc
@item Purpose
Retrieve port used by local host
@item Prototype
@deftypefn Sockets.Naming.Get_Sock_Port function Get_Sock_Port (@w{@var{Socket} : Socket_FD})@*@w{return Positive;}
@end deftypefn
@fnindex Sockets.Naming.Get_Sock_Port

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Socket} @tab in @tab Connected socket object
@end multitable

@item Return value
Port used on the local host




@item See also
@ref{Get_Peer_Port (function)},@*@ref{Get_Sock_Addr (function)}.

@end table

@node Host_Name (function)
@unnumberedsubsec Host_Name (function)

@table @sc
@item Purpose
Get the name of the current host
@item Prototype
@deftypefn Sockets.Naming.Host_Name function Host_Name
@end deftypefn
@fnindex Sockets.Naming.Host_Name

@item Return value
Name of the current host

@item Description
This function returns the name of the current host. Depending on
the local configuration, it may or may not be a fully qualified
domain name (FQDN).




@end table

@node Image (function)
@unnumberedsubsec Image (function)
@cindex Representing IP addresses

@table @sc
@item Purpose
Make a string from an address
@item Prototype
@deftypefn Sockets.Naming.Image function Image (@w{@var{Add} : Address})@*@w{return String;}
@end deftypefn
@fnindex Sockets.Naming.Image

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Add} @tab in @tab IP address
@end multitable

@item Return value
String representation of the IP address




@item See also
@ref{Value (function)}.

@end table

@node Info_Of_Name_Or_IP (function)
@unnumberedsubsec Info_Of_Name_Or_IP (function)

@table @sc
@item Purpose
Get addresses and names of a host
@item Prototype
@deftypefn Sockets.Naming.Info_Of_Name_Or_IP function Info_Of_Name_Or_IP (@w{@var{Something} : String})@*@w{return Host_Entry;}
@end deftypefn
@fnindex Sockets.Naming.Info_Of_Name_Or_IP

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab Host name or IP address
@end multitable

@item Return value
Corresponding host entry

@item Description
This function extracts all the names and addresses from the
naming service.


@item Exceptions
@multitable {XXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @code{Naming_Error} @tab No information available for this name or address@exindex Naming_Error
@end multitable





@end table

@node Is_IP_Address (function)
@unnumberedsubsec Is_IP_Address (function)

@table @sc
@item Purpose
Check if given string is a valid IP address
@item Prototype
@deftypefn Sockets.Naming.Is_IP_Address function Is_IP_Address (@w{@var{Something} : String})@*@w{return Boolean;}
@end deftypefn
@fnindex Sockets.Naming.Is_IP_Address

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab String to check
@end multitable

@item Return value
@samp{True} if @var{Something} is an IP address




@end table

@node Name_Of (function)
@unnumberedsubsec Name_Of (function)

@table @sc
@item Purpose
Official name of the host
@item Prototype
@deftypefn Sockets.Naming.Name_Of function Name_Of (@w{@var{Something} : String})@*@w{return String;}
@end deftypefn
@fnindex Sockets.Naming.Name_Of

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Something} @tab in @tab Host name or IP address
@end multitable

@item Return value
Name of the host


@item Exceptions
@multitable {XXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @code{Naming_Error} @tab No information available for this name or address@exindex Naming_Error
@end multitable





@item See also
@ref{Address_Of (function)}.

@end table

@node Value (function)
@unnumberedsubsec Value (function)
@cindex Representing IP addresses

@table @sc
@item Purpose
Transform a string into an address
@item Prototype
@deftypefn Sockets.Naming.Value function Value (@w{@var{Add} : String})@*@w{return Address;}
@end deftypefn
@fnindex Sockets.Naming.Value

@item Parameters
@multitable {XXXXXXXX} {in out X} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
@item @var{Add} @tab in @tab Textual representation of an IP address
@end multitable

@item Return value
Corresponding Address




@item See also
@ref{Image (function)}.

@end table