.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) .\" Portions extracted from /usr/include/sys/socket.h, which does not have .\" any authorship information in it. It is probably available under the GPL. .\" .\" 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 that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" .\" Other portions are from the 6.9 (Berkeley) 3/10/91 man page: .\" .\" Copyright (c) 1983 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" Modified Mon Oct 21 23:05:29 EDT 1996 by Eric S. Raymond .\" Modified 1998 by Andi Kleen .\" $Id: bind.2,v 1.2 2000/11/09 15:55:06 ricardo Exp $ .TH BIND 2 "3 Outubro 1998" "Linux 2.2" "Manual do Programador Linux" .SH NOME bind \- associa um nome a um soquete .SH SINOPSE .B #include .br .B #include .sp .BI "int bind(int " sockfd ", struct sockaddr *" my_addr ", socklen_t " addrlen ); .SH DESCRIÇÃO .B bind dá ao soquete .I sockfd o endereço local .IR my_addr . .I my_addr tem .I addrlen bytes de tamanho. Tradicionalmente, isso é chamado \(lqatribuindo um nome a um soquete.\(rq Quando um soquete é criado com .BR socket (2), ele existe no espaço de nomes (familia de endereços) mas não possui um nome atribuído. .PP É normalmente necessário atribuir um endereço local usando .B bind para que um soquete .B SOCK_STREAM possa receber conexões (veja .BR accept (2)). .SH NOTAS As regras usadas na associação de nomes variam entre as familias de endereços. Consulte a entrada do manual na Seção 7 para informações detalhadas. Para .B AF_INET veja .BR ip (7), para .B AF_UNIX veja .BR unix (7), para .B AF_APPLETALK veja .BR ddp (7), para .B AF_PACKET veja .BR packet (7), para .B AF_X25 veja .BR x25 (7) e para .B AF_NETLINK veja .BR netlink (7). .SH "VALOR DE RETORNO" Em caso de sucesso, é retornado zero. Em caso de erro, é retornado \-1, e .I errno é ajustado apropriadamente. .SH ERROS .TP .B EBADF .I sockfd não é um descritor válido. .TP .B EINVAL O soquete já está limitado a um endereço. Isso pode mudar no futuro: veja .I linux/unix/sock.c para detalhes. .TP .B EACCES O endereço está protegido, e o usuário não é o super-usuário. .TP .B ENOTSOCK Argumento é um descritor para um arquivo, não um soquete. .PP Os erros a seguir são específicos para soquetes de domínio UNIX .RB ( AF_UNIX ) : .TP .B EINVAL O .I addrlen está errado, ou o soquete não está na família .B AF_UNIX . .TP .B EROFS O inode do soquete pode estar residente em um sistema de arquivos somente leitura. .TP .B EFAULT .I my_addr aponta para fora de um espaço de endereçamento acessível pelo usuário. .TP .B ENAMETOOLONG .I my_addr é muito longo. .TP .B ENOENT O arquivo não existe. .TP .B ENOMEM A memória do kernel disponível foi insuficiente. .TP .B ENOTDIR Um componente do prefixo do caminho não é um diretório. .TP .B EACCES Permissão de procura negada em um componente do prefixo do caminho. .TP .B ELOOP Muitas ligações simbólicas foram encontradas resolvendo .IR my_addr . .SH BUGS As opções de proxy transparente não são descritas. .SH CONFORMIDADE SVr4, 4.4BSD (a função .B bind apareceu primeiramente no BSD 4.2). SVr4 documenta adicionalmente as condições de erro gerais .BR EADDRNOTAVAIL , .BR EADDRINUSE , e .BR ENOSR , e adicionalmente condições de erro de domínio Unix .BR EIO , .B EISDIR e .BR EROFS . .SH NOTA O terceiro argumento de .B bind é na realidade um int (e isso é o que BSD 4.* e libc4 e libc5 usam). Alguma confusão no POSIX resultou no presente socklen_t. O esboço padrão não foi adotado ainda, mas a glibc2 já segue isso e também usa socklen_t. Veja também .BR accept (2). .SH "VEJA TAMBÉM" .BR accept (2), .BR connect (2), .BR listen (2), .BR socket (2), .BR getsockname (2), .BR ip (7), .BR socket (7) .SH TRADUZIDO POR LDP-BR em 21/08/2000. \&\fR\&\f(CWMarcelo D. Beckmann (tradução)\fR \&\fR\&\f(CWFábio Henrique F. Silva (revisão)\fR