Stay organized with collections
Save and categorize content based on your preferences.
Traffic from sockets is billed as
outgoing bandwidth.
App Engine supports outbound sockets using methods from the standard PHP
library such as fsockopen.
For supported options, calls to
socket_get_option
will return a mock value and calls to
socket_set_option
will be silently ignored. Errors will continue to be raised for unsupported options.
The supported options are:
SO_KEEPALIVE
SO_DEBUG
TCP_NODELAY
SO_LINGER
SO_OOBINLINE
SO_SNDBUF
SO_RCVBUF
SO_REUSEADDR
Limitations and restrictions
Socket support in App Engine has the following limitations:
You cannot create a listen socket; you can only create outbound sockets.
FTP is not supported.
You can only use TCP or UDP; arbitrary protocols are not allowed.
You cannot bind to specific IP addresses or ports.
Port 25 (SMTP) is blocked; you can still use authenticated SMTP on the
submission port 587.
Private, broadcast, multicast, and Google IP ranges are blocked, except
those listed below:
Google Public DNS: 8.8.8.8, 8.8.4.4, 2001:4860:4860::8888,
2001:4860:4860::8844 port 53
Gmail SMTPS: smtp.gmail.com port 465 and 587
Gmail POP3S: pop.gmail.com port 995
Gmail IMAPS: imap.gmail.com port 993
Socket descriptors are associated with the App Engine app that
created them and are non-transferable (cannot be used by other apps).
Sockets may be reclaimed after 10 minutes of inactivity; any socket operation
keeps the socket alive for a further 10 minutes.
Using sockets with the development server
You can run and test code using sockets on the development server, without using
any special command line parameters.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-05 UTC."],[[["This 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."],["App Engine supports outbound sockets through standard PHP library methods like `fsockopen`, with limited options for `socket_get_option` and `socket_set_option`."],["Only outbound sockets are allowed; creating listen sockets is not possible, and certain protocols like FTP and arbitrary protocols are unsupported."],["Specific 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."],["Sockets are non-transferable and may be automatically reclaimed after 10 minutes of inactivity, with any socket operation extending their life by another 10 minutes."]]],[]]