- ·上一篇文章:CoffeeScript 网络
- ·下一篇文章:CoffeeScript HTTP 客户端
当前位置:K88软件开发 → 文章中心 → 编程语言 → JavaScript → CoffeeScript → 文章内容
CoffeeScript 客户端
由 珍珍阿姨 创建,Carrie 最后一次修改 2016-08-12 客户端问题你想使用网络上提供的服务。解决方案创建一个基本的TCP客户机。在 Node.js 中net = require 'net'domain = 'localhost'port = 9001connection = net.createConnection port, domainconnection.on 'connect', () -> console.log "Opened connection to #{domain}:#{port}."connection.on 'data', (data) -> console.log "Received: #{data}" connection.end()使用示例可访问Basic Server :$ coffee basic-client.coffeeOpened connection to localhost:9001Received: Hello, World!讨论最重要的工作发生在connection.on 'data'处理过程中,客户端接收到来自服务器的响应并最有可能安排对它的应答。另请参阅Basic Server,Bi-Directional Client和Bi-Directional Server 。 练习根据命令行参数或配置文件为选定的目标域和端口添加支持。
CoffeeScript 客户端