API de Sockets para servicios agrupados en paquetes heredados
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
El tráfico de los sockets se factura como el
ancho de banda saliente.
App Engine admite sockets salientes mediante métodos de la biblioteca estándar de PHP, como fsockopen.
En las opciones compatibles, las llamadas a socket_get_option mostrarán un valor simulado y las llamadas a socket_set_option se ignorarán de forma silenciosa. Se continuarán generando errores para las opciones no admitidas.
Las opciones compatibles son las siguientes:
SO_KEEPALIVE
SO_DEBUG
TCP_NODELAY
SO_LINGER
SO_OOBINLINE
SO_SNDBUF
SO_RCVBUF
SO_REUSEADDR
Limitaciones y restricciones
La compatibilidad de los sockets en App Engine tiene las siguientes limitaciones:
No puedes crear un socket de escucha; solo puedes crear sockets de salida.
FTP no es compatible.
Solo puedes usar TCP o UDP; no se permiten protocolos arbitrarios.
No puedes establecer una vinculación con puertos o direcciones IP específicos.
El puerto 25 (SMTP) está bloqueado; pero aún puedes usar el SMTP autenticado en el puerto de envío 587.
Los rangos de IP privados, de transmisión, de multidifusión y de Google están bloqueados, excepto los que se indican a continuación:
DNS público de Google: 8.8.8.8, 8.8.4.4, 2001:4860:4860::8888, 2001:4860:4860::8844 puerto 53
SMTP de Gmail: smtp.gmail.com, puertos 465 y 587
POP3 de Gmail: pop.gmail.com puerto 995
IMAP de Gmail: imap.gmail.com puerto 993
Los descriptores de socket están asociados con la aplicación de App Engine que los creó y no se pueden transferir (no pueden usarse en otras apps).
Los sockets pueden recuperarse después de 10 minutos de inactividad; cualquier operación de socket lo mantiene en funcionamiento durante otros 10 minutos.
Usa sockets con el servidor de desarrollo
Puedes ejecutar y probar el código con sockets en el servidor de desarrollo, sin usar ningún parámetro de línea de comandos especial.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eThis socket API is not recommended anymore, as apps using it are limited to the PHP 5 runtime and need to migrate to a different solution before upgrading to PHP 7/8.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine supports outbound sockets through standard PHP library methods like \u003ccode\u003efsockopen\u003c/code\u003e, with limited options for \u003ccode\u003esocket_get_option\u003c/code\u003e and \u003ccode\u003esocket_set_option\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eOnly outbound sockets are allowed; creating listen sockets is not possible, and certain protocols like FTP and arbitrary protocols are unsupported.\u003c/p\u003e\n"],["\u003cp\u003eSpecific restrictions apply, such as the inability to bind to specific IPs or ports, the blocking of port 25, and the blocking of private, broadcast, and multicast IP ranges, except for specific Google services like Google Public DNS and Gmail.\u003c/p\u003e\n"],["\u003cp\u003eSockets are non-transferable and may be automatically reclaimed after 10 minutes of inactivity, with any socket operation extending their life by another 10 minutes.\u003c/p\u003e\n"]]],[],null,["# Sockets API for legacy bundled services\n\n| **Caution:** **This solution is no longer recommended:** Apps that use this API can only run in the PHP 5 runtime and will need to upgrade to a [recommended solution](/appengine/migration-center/standard/services/migrating-services) before migrating to the PHP 7/8 runtime.\n\nTraffic from sockets is billed as [outgoing bandwidth](/appengine/docs/pricing#Billable_Resource_Unit_Costs). App Engine supports outbound sockets using methods from the standard PHP library such as [`fsockopen`](http://www.php.net/function.fsockopen). For supported options, calls to [`socket_get_option`](http://php.net/manual/en/function.socket-get-option.php) will return a mock value and calls to [`socket_set_option`](http://www.php.net/manual/en/function.socket-set-option.php) will be silently ignored. Errors will continue to be raised for unsupported options. The supported options are:\n\n\u003cbr /\u003e\n\n- `SO_KEEPALIVE`\n- `SO_DEBUG`\n- `TCP_NODELAY`\n- `SO_LINGER`\n- `SO_OOBINLINE`\n- `SO_SNDBUF`\n- `SO_RCVBUF`\n- `SO_REUSEADDR`\n\nLimitations and restrictions\n----------------------------\n\nSocket support in App Engine has the following limitations:\n\n- You cannot create a listen socket; you can only create outbound sockets.\n- FTP is not supported.\n- You can only use TCP or UDP; arbitrary protocols are not allowed.\n- You cannot bind to specific IP addresses or ports.\n- Port 25 (SMTP) is blocked; you can still use authenticated SMTP on the submission port 587.\n- Private, broadcast, multicast, and Google IP ranges are blocked, except\n those listed below:\n\n - Google Public DNS: `8.8.8.8`, `8.8.4.4`, `2001:4860:4860::8888`, `2001:4860:4860::8844` port 53\n - Gmail SMTPS: `smtp.gmail.com` port 465 and 587\n - Gmail POP3S: `pop.gmail.com` port 995\n - Gmail IMAPS: `imap.gmail.com` port 993\n\n | **Note:** Google Compute Engine IP addresses are not considered to be in Google IP ranges. You can use sockets to connect App Engine apps to Compute Engine instances.\n- Socket descriptors are associated with the App Engine app that\n created them and are non-transferable (cannot be used by other apps).\n\n- Sockets may be reclaimed after 10 minutes of inactivity; any socket operation\n keeps the socket alive for a further 10 minutes.\n\n\n Using sockets with the development server\n -----------------------------------------\n\n You can run and test code using sockets on the development server, without using\n any special command line parameters."]]