Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Le trafic provenant des sockets est facturé en tant que bande passante sortante.
App Engine est compatible avec les sockets sortants, à condition d'utiliser les méthodes de la bibliothèque PHP standard, par exemple fsockopen.
Pour les options compatibles, les appels à socket_get_option affichent une valeur fictive, et les appels à socket_set_option sont ignorés sans notification. Les erreurs continuent d'être générées pour les options non compatibles.
Les options compatibles sont les suivantes :
SO_KEEPALIVE
SO_DEBUG
TCP_NODELAY
SO_LINGER
SO_OOBINLINE
SO_SNDBUF
SO_RCVBUF
SO_REUSEADDR
Limites et restrictions
Dans App Engine, la compatibilité avec les sockets présente les limitations suivantes :
Vous ne pouvez pas créer de socket d'écoute et vous ne pouvez créer que des sockets sortants.
Le protocole FTP n'est pas compatible.
Seuls les protocoles TCP ou UDP peuvent être utilisés ; les protocoles arbitraires ne sont pas autorisés.
Vous ne pouvez pas établir de liaisons à des adresses IP ou des ports spécifiques.
Le port 25 (SMTP) est bloqué. Vous pouvez utiliser le protocole SMTP authentifié sur le port de soumission 587.
Les plages IP privées, de diffusion, de multidiffusion et Google, à l'exception de celles énumérées ci-dessous, sont bloquées :
DNS public de Google : 8.8.8.8, 8.8.4.4, 2001:4860:4860::8888, 2001:4860:4860::8844 (port 53)
Gmail SMTPS : smtp.gmail.com (ports 465 et 587)
Gmail POP3S : pop.gmail.com (port 995)
Gmail IMAPS : imap.gmail.com (port 993)
Les descripteurs de socket sont associés à l'application App Engine qui les a créés et ne sont pas transférables (ils ne peuvent pas être utilisés par d'autres applications).
Les sockets peuvent être récupérés après 10 minutes d'inactivité. Toute opération de socket maintient le socket en vie pendant 10 minutes supplémentaires.
Utiliser des sockets avec le serveur de développement
Vous pouvez exécuter et tester du code à l'aide de sockets sur le serveur de développement, sans utiliser de paramètres de ligne de commande spéciaux.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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."]]