Anthony Hunt
Anthony Hunt

Reputation: 1610

Can I use sockets on Appengine without a special lib?

I'm confused by the GAE documentations. It says App Engine supports sockets without requiring you to import any special App Engine libraries or add any special App Engine code. but it seems misleading as just above it says App Engine supports outbound sockets through the appengine/socket package.

I would like to connect to an IMAP server using the standard net package. Is that possible or I'm stuck with the GAE sockets API?

https://cloud.google.com/appengine/docs/go/sockets/

Upvotes: 1

Views: 625

Answers (2)

Logiraptor
Logiraptor

Reputation: 1518

It is not possible to open an outbound socket without going through the appengine/socket api. This is because it works through RPC and an appengine.Context is needed to do that. You can still use the IMAP library you linked, though, as it provides a function to create a client with a given net.Conn. You can get a net.Conn from appengine/socket and pass it to NewClient to do your business. The reason it works on python and java is because they both use thread local memory to manage request state implicitly, whereas the go runtime does not.

Upvotes: 2

koma
koma

Reputation: 6566

Nothing stops you from connecting to an Imap server, since you will initiate an outbound connection. For java, the standard java mail packages work out of the box. Only for paid apps though, i.e. you need to have billing enabled.

Upvotes: 1

Related Questions