.\" -*- coding: UTF-8 -*- .\" 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. .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" .\" 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. .\" .\" SPDX-License-Identifier: BSD-4-Clause-UC .\" .\" Modified 1997-01-31 by Eric S. Raymond .\" Modified 1998, 1999 by Andi Kleen .\" Modified 2004-06-23 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH connect 2 "2 Mayo 2024" "Páginas de Manual de Linux 6.8" .SH NOMBRE connect \- inicia una conexión en un conector (socket) .SH BIBLIOTECA Biblioteca Estándar C (\fIlibc\fP, \fI\-lc\fP) .SH SINOPSIS .nf \fB#include \fP .P \fBint connect(int \fP\fIsockfd\fP\fB, const struct sockaddr *\fP\fIaddr\fP\fB,\fP \fB socklen_t \fP\fIaddrlen\fP\fB);\fP .fi .SH DESCRIPCIÓN The \fBconnect\fP() system call connects the socket referred to by the file descriptor \fIsockfd\fP to the address specified by \fIaddr\fP. The \fIaddrlen\fP argument specifies the size of \fIaddr\fP. The format of the address in \fIaddr\fP is determined by the address space of the socket \fIsockfd\fP; see \fBsocket\fP(2) for further details. .P If the socket \fIsockfd\fP is of type \fBSOCK_DGRAM\fP, then \fIaddr\fP is the address to which datagrams are sent by default, and the only address from which datagrams are received. If the socket is of type \fBSOCK_STREAM\fP or \fBSOCK_SEQPACKET\fP, this call attempts to make a connection to the socket that is bound to the address specified by \fIaddr\fP. .P Some protocol sockets (e.g., UNIX domain stream sockets) may successfully \fBconnect\fP() only once. .P Some protocol sockets (e.g., datagram sockets in the UNIX and Internet domains) may use \fBconnect\fP() multiple times to change their association. .P Some protocol sockets (e.g., TCP sockets as well as datagram sockets in the UNIX and Internet domains) may dissolve the association by connecting to an address with the \fIsa_family\fP member of \fIsockaddr\fP set to \fBAF_UNSPEC\fP; thereafter, the socket can be connected to another address. (\fBAF_UNSPEC\fP is supported since Linux 2.2.) .SH "VALOR DEVUELTO" Si la conexión o enlace tiene éxito, se devuelve 0. En caso de error, se devuelve \-1, y se asigna a la variable \fIerrno\fP un valor apropiado. .SH ERRORES Los siguientes sólo son errores generales de conector. Puede haber otros códigos de error específicos del dominio. .TP \fBEACCES\fP For UNIX domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path prefix. (See also \fBpath_resolution\fP(7).) .TP \fBEACCES\fP .TQ \fBEPERM\fP El usuario ha intentado conectarse a una dirección de difusión (broadcast) sin que el conector tenga activa la opción de difusión, o la petición de conexión ha fallado debido a una regla del cortafuegos local. .TP \fBEACCES\fP It can also be returned if an SELinux policy denied a connection (for example, if there is a policy saying that an HTTP proxy can only connect to ports associated with HTTP servers, and the proxy tries to connect to a different port). .TP \fBEADDRINUSE\fP La dirección local ya está en uso. .TP \fBEADDRNOTAVAIL\fP (Internet domain sockets) The socket referred to by \fIsockfd\fP had not previously been bound to an address and, upon attempting to bind it to an ephemeral port, it was determined that all port numbers in the ephemeral port range are currently in use. See the discussion of \fI/proc/sys/net/ipv4/ip_local_port_range\fP in \fBip\fP(7). .TP \fBEAFNOSUPPORT\fP La dirección pasada no tiene la familia de direcciones correcta en su campo \fIsa_family\fP. .TP \fBEAGAIN\fP For nonblocking UNIX domain sockets, the socket is nonblocking, and the connection cannot be completed immediately. For other socket families, there are insufficient entries in the routing cache. .TP \fBEALREADY\fP El conector es no bloqueante y todavía no se ha terminado un intento de conexión anterior. .TP \fBEBADF\fP \fIsockfd\fP no es descriptor válido de archivos abiertos. .TP \fBECONNREFUSED\fP Un \fBconnect\fP() en un conector de flujo, no ha econtrado a nadie a la esucha en la dirección remota. .TP \fBEFAULT\fP La estructura de dirección del conector está fuera del espacio de direcciones del usuario. .TP \fBEINPROGRESS\fP The socket is nonblocking and the connection cannot be completed immediately. (UNIX domain sockets failed with \fBEAGAIN\fP instead.) It is possible to \fBselect\fP(2) or \fBpoll\fP(2) for completion by selecting the socket for writing. After \fBselect\fP(2) indicates writability, use \fBgetsockopt\fP(2) to read the \fBSO_ERROR\fP option at level \fBSOL_SOCKET\fP to determine whether \fBconnect\fP() completed successfully (\fBSO_ERROR\fP is zero) or unsuccessfully (\fBSO_ERROR\fP is one of the usual error codes listed here, explaining the reason for the failure). .TP \fBEINTR\fP .\" For TCP, the connection will complete asynchronously. .\" See http://lkml.org/lkml/2005/7/12/254 La señal atrapada ha interrumpido la llamada del sistema; consulte \fBsignal\fP(7). .TP \fBEISCONN\fP El conector ya está conectado. .TP \fBENETUNREACH\fP Red inaccesible. .TP \fBENOTSOCK\fP El descriptor de archivo \fIsockfd\fP no se refiere a un conector. .TP \fBEPROTOTYPE\fP The socket type does not support the requested communications protocol. This error can occur, for example, on an attempt to connect a UNIX domain datagram socket to a stream socket. .TP \fBETIMEDOUT\fP Finalizó el plazo de tiempo mientras se intentaba la conexión. El servidor puede estar demasiado ocupado para aceptar nuevas conexiones. Dese cuenta que para conectores IP el plazo de tiempo puede ser muy largo cuando se han habilitado los "syncookies" en el servidor. .SH ESTÁNDARES POSIX.1\-2008. .SH HISTORIAL .\" SVr4 documents the additional .\" general error codes .\" .BR EADDRNOTAVAIL , .\" .BR EINVAL , .\" .BR EAFNOSUPPORT , .\" .BR EALREADY , .\" .BR EINTR , .\" .BR EPROTOTYPE , .\" and .\" .BR ENOSR . .\" It also .\" documents many additional error conditions not described here. POSIX.1\-2001, SVr4, 4.4BSD, (\fBconnect\fP() first appeared in 4.2BSD). .SH NOTAS If \fBconnect\fP() fails, consider the state of the socket as unspecified. Portable applications should close the socket and create a new one for reconnecting. .SH EJEMPLOS En \fBgetaddrinfo\fP(3) tiene un ejemplo del uso de \fBconnect\fP(). .SH "VÉASE TAMBIÉN" \fBaccept\fP(2), \fBbind\fP(2), \fBgetsockname\fP(2), \fBlisten\fP(2), \fBsocket\fP(2), \fBpath_resolution\fP(7), \fBselinux\fP(8) .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Miguel Angel Sepulveda , Cesar D. Lobejon , Juan Piernas y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .