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
|
\input texinfo @c -*-texinfo-*-
@setfilename adasockets.info
@settitle AdaSockets reference manual
@setchapternewpage odd
@include version.texi
@ifinfo
@format
START-INFO-DIR-ENTRY
* adasockets: (adasockets). AdaSockets reference manual
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@ifinfo
Copyright @copyright{} 2002-2004 Samuel Tardieu
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries a copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end ifinfo
@titlepage
@finalout
@title AdaSockets reference manual
@subtitle for AdaSockets version @value{VERSION}
@subtitle @value{UPDATED}
@author Samuel Tardieu
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 2002-2004 Samuel Tardieu
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end titlepage
@c New indices: constants (ct) and exceptions (ex)
@defindex ct
@defindex ex
@syncodeindex ex cp
@syncodeindex ct cp
@syncodeindex vr cp
@syncodeindex fn cp
@syncodeindex tp cp
@contents
@c ---------------------------------------------------------------
@node Top, What is AdaSockets?, (dir), (dir)
@menu
* What is AdaSockets?::
* Installing AdaSockets::
* Using AdaSockets::
* Sockets package::
* Sockets.Multicast package::
* Sockets.Naming package::
* Contributors::
* Resources on the Internet::
* Index::
@detailmenu
--- The Detailed Node Listing ---
Using AdaSockets
* Compiling an Ada application::
* Setting up unicast sockets::
* Setting up multicast sockets::
* Sending and receiving data::
Sending and receiving data
* Raw data manipulation::
* String-oriented exchanges::
@end detailmenu
@end menu
@node What is AdaSockets?, Installing AdaSockets, Top, Top
@chapter What is AdaSockets?
@cindex AdaSockets presentation
@cindex Comparaison with @code{GNAT.Sockets}
AdaSockets is a set of free software Ada packages allowing Ada
programmers to use the so-called BSD sockets from their favourite
programming language. AdaSockets has been designed and tested with the
GNAT free software Ada compiler, but should be portable to other
compilers quite easily.
Starting from release 3.14, the GNAT compiler started to integrate a
@code{GNAT.Sockets} package. However, this package is GNAT specific and
contains at this time less features than AdaSockets. At some point,
AdaSockets may use @code{GNAT.Sockets} as its underlying sockets structure.
AdaSockets philosophy is to help the Ada programmer by providing
easy-to-use objects. Special care has been taken to ensure that
performances do however remain good.
@node Installing AdaSockets, Using AdaSockets, What is AdaSockets?, Top
@chapter Installing AdaSockets
@cindex Installing AdaSockets
Installing AdaSockets on a Unix or OpenVMS machine is as simple as
typing a few commands. Once you got the latest version of AdaSockets
(@pxref{Resources on the Internet}), uncompress and untar it and go to
the top-level directory of the distribution.
You must configure the AdaSockets distribution by using the
@command{configure} command, such as in:
@example
./configure --prefix=/users/sam/adasockets
@end example
If you want to install AdaSockets under the @file{/usr/local} hierarchy,
you do not need to specify the @option{--prefix} option. Make sure you
have write permission on the target directories.
Once AdaSockets is configured, you can compile and install it by using the
@command{make} command:
@example
make install
@end example
The GNU make program is recommended but not mandatory. On your system,
it may be installed under the @command{gmake} name.
@node Using AdaSockets, Sockets package, Installing AdaSockets, Top
@chapter Using AdaSockets
@menu
* Compiling an Ada application::
* Setting up unicast sockets::
* Setting up multicast sockets::
* Sending and receiving data::
@end menu
@node Compiling an Ada application, Setting up unicast sockets, Using AdaSockets, Using AdaSockets
@section Compiling an Ada application
AdaSockets comes with an @code{adasockets-config} application that can
be used to retrieve installation parameters while using @code{gnatmake}
to compile your Ada application. The @code{--cflags} parameters tells
@code{adasockets-config} to output the path to the Ada packages sources,
while @code{--libs} asks for the path to the Ada library.
@example
gnatmake `adasockets-config --cflags` mainprog
-largs `adasockets-config --libs`
@end example
@node Setting up unicast sockets, Setting up multicast sockets, Compiling an Ada application, Using AdaSockets
@section Setting up unicast sockets
@cindex Unicast sockets
@cindex Creating a unicast socket
@cindex Creating a TCP socket
@cindex Creating a UDP socket
@cindex TCP socket
@cindex UDP socket
@cindex Creating a socket
@tindex Socket_FD
@findex Sockets.Socket
@findex Socket
Unicast sockets are used everywhere on the Internet, for surfing the
web, sending electronic mails or accessing remote files. They come in
two flavours:
@table @asis
@item TCP
TCP is a connected mode, in which packets are sent in a reliable and
ordered way. Everything sent at one end will eventually arrive in the
same order at the other end, the underlying operating system takes care
of retransmitting missing packets and reordering out-of-order ones.
@item UDP
UDP is a non-connected mode. A packet sent on a UDP socket may or may
not arrive at the other end. This is a much lighter protocol when
reliability is not needed as the operating system does not have to use
large buffers to reorder packets. Also, this generates less traffic as
no acknowledgments need to be sent by the kernels.
@end table
The package @code{Sockets} defines a @code{Socket_FD} tagged type. An
instance of this type (or of any of its descendants) represents an
incoming or outgoing socket. Two different kinds of sockets can be
created: unicast (one-to-one) and multicast (many-to-many).
@node Setting up multicast sockets, Sending and receiving data, Setting up unicast sockets, Using AdaSockets
@section Setting up multicast sockets
@cindex Multicast sockets
@cindex Creating a multicast socket
@cindex Mbone
@cindex Group communication
Multicast sockets are used for group communication over the Internet. To
use multicast sockets, you must be connected to a multicast
network and use a multicast-enabled operating system (such as most
Unices, Linux or even recent Windows versions). Unless you are connected
to the mbone (multicast backbone) or have setup a private multicast
network, you will only be able to use multicast on your local network.
A multicast socket is somewhat similar to a UDP socket; in particular,
packets may be lost or misordered.
@findex Create_Multicast_Socket
@findex Sockets.Multicast.Create_Multicast_Socket
@tindex Multicast_Socket_FD
You can create a multicast socket using the function
@code{Create_Multicast_Socket} in the package
@code{Sockets.Multicast}. This function returns a
@code{Multicast_Socket_FD} object, which derives from @code{Socket_FD}.
@code{Create_Multicast_Socket} takes care of the whole setup of your
multicast socket. You do not need to call any additionnal subprogram
before using it. In particular, @code{Create_Multicast_Socket} will take
care of registering the multicast socket to the operating system, so
that the latter can tell the connected routers to propagate the
subscription to the mbone as needed.
@node Sending and receiving data, , Setting up multicast sockets, Using AdaSockets
@section Sending and receiving data
@cindex Sending data
@cindex Receiving data
In AdaSockets, data can be sent and received in three different ways:
raw, string-oriented and stream-oriented.
@menu
* Raw data manipulation::
* String-oriented exchanges::
@end menu
@node Raw data manipulation, String-oriented exchanges, Sending and receiving data, Sending and receiving data
@subsection Raw data manipulation
@cindex Raw data manipulation
@tindex Ada.Streams.Stream_Element_Array
@tindex Stream_Element_Array
Raw data is manipulated using the predefined
@code{Ada.Streams.Stream_Element_Array} Ada type. This corresponds to an
array of bytes, or an @code{unsigned char *} in the C programming
language.
@node String-oriented exchanges, , Raw data manipulation, Sending and receiving data
@subsection String-oriented exchanges
String-oriented exchanges provides the programmer with @code{Ada.Text_IO}
like subprograms. Most Internet protocols are line-oriented and those
subprograms are perfectly suited to implement those.
When sending data, the classical @code{CR + LF} sequence will be sent at
the end of each line. When receiving data, @code{CR} characters are
discarded and @code{LF} is used as the end-of-line marker.
The @code{Get} function is tied to the size of the operating system
buffer. It is better to use @code{Get_Line} to get a full line. The line
can be as long as the length of the Ada buffer. The Ada buffer can be
adjusted by using the @code{Set_Buffer} and @code{Unset_Buffer}
procedures.
When using string-oriented exchanges with datagram protocols such as UDP,
setting a buffer using @code{Set_Buffer} for the receiving socket is
mandatory. If you don't, the receiving socket will loose data and will be
unable to reconstitute the string.
@node Sockets package, Sockets.Multicast package, Using AdaSockets, Top
@chapter Sockets package
@include sockets.texi
@node Sockets.Multicast package, Sockets.Naming package, Sockets package, Top
@chapter Sockets.Multicast package
@include sockets-multicast.texi
@node Sockets.Naming package, Contributors, Sockets.Multicast package, Top
@chapter Sockets.Naming package
@include sockets-naming.texi
@node Contributors, Resources on the Internet, Sockets.Naming package, Top
@appendix Contributors
@cindex Contributing
AdaSockets has been originally developped by Samuel Tardieu who still
maintains it. However, the following people have made crucial
contributions to AdaSockets, be they new code, bug fixes or porting to
new operating systems:
@itemize @bullet
@item Dmitriy Anisimkov (@email{anisimkov@@yahoo.com})
@item Alan Barnes (@email{barnesa@@aston.ac.uk})
@item Juanma Barranquero (@email{lektu@@terra.es})
@item Bobby D. Bryant (@email{bdbryant@@mail.utexas.edu})
@item Sander Cox (@email{sander.cox@@philips.com})
@item Sune Falk (@email{sune.falck@@telia.com})
@item Guillaume Foliard (@email{guifo@@wanadoo.fr})
@item Laurent Guerby (@email{guerby@@club-internet.fr})
@item David J. Kristola (@email{David95037@@aol.com})
@item Dominik Madon (@email{dominik@@acm.org})
@item Pascal Obry (@email{p.obry@@wanadoo.fr})
@item Nicolas Ollinger (@email{Nicolas.Ollinger@@ens-lyon.fr})
@item Stphane Patureau (@email{spaturea@@meletu.univ-valenciennes.fr})
@item Thomas Quinot (@email{thomas@@cuivre.fr.eu.org})
@item Preben Randhol (@email{randhol@@pvv.org})
@item Maxim Reznik (@email{max1@@mbank.com.ua})
@item Samuel Tardieu (@email{sam@@rfc1149.net})
@end itemize
If you feel that you have been forgotten, please send me a mail so that
I can fix it in the next version.
@xref{Resources on the Internet}, for how to contribute.
@node Resources on the Internet, Index, Contributors, Top
@appendix Resources on the Internet
@cindex Sending patches
@cindex Reporting a bug
@cindex Suggesting a feature
@cindex Finding AdaSockets on the Internet
@cindex Contributing
The latest version of AdaSockets can always be found at:
@center @url{http://www.rfc1149.net/devel/adasockets}
There is a mailing-list that you can use to discuss problem or
suggestions at:
@center @url{http://www.rfc1149.net/lists/info/adasockets}
Please use the mailing-list for questions and discussions. However, you
can send me patches by private mail (@email{sam@@rfc1149.net}).
@node Index, , Resources on the Internet, Top
@unnumbered Index
@printindex cp
@bye
|