EDOBE XDOM TAKE 6 IR - PRODUCTSHEET Especificações Página 196

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 304
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 195
CHAPTER 6: External Communication Tools Socket object 196
// poll for a new connection
var connection = tcp.poll();
if (connection != null) {
writeln ("Connection from " + connection.host);
// we have a new connection, so welcome and chat
// until client terminates the session
connection.writeln ("Welcome to a little chat!");
chat (connection);
connection.writeln ( "*** Goodbye ***");
connection.close();
delete connection;
writeln ("Connection closed");
}
}
}
}
function chatClient() {
var connection = new Socket;
// connect to sample server
if (connection.open ("remote-pc.corp.adobe.com:1234")) {
// then chat with server
chat (connection);
connection.close();
delete connection;
}
}
function chat (c) {
// select a long timeout
c.timeout=1000;
while (true) {
// get one line and echo it
writeln (c.read());
// stop if the connection is broken
if (!c.connected)
break;
// read a line of text
write ("chat: ");
var text = readln();
if (text == "bye")
// stop conversation if the user entered "bye"
break;
else
// otherwise transmit to server
c.writeln (text);
}
}
Vista de página 195
1 2 ... 191 192 193 194 195 196 197 198 199 200 201 ... 303 304

Comentários a estes Manuais

Sem comentários