I believe 30 here is the number of bytes written. What I think you want to do after the write()
is a readline(imap)
when will read a single line back from the server.
EDIT: Thinking about it, since the interface seems to be text you probably want to do:
println(imap, "01 AUTH user_foo password_bar")
Instead of write
so that a \n
is sent to the server, it may be waiting for that to complete the line of text.