13.07.2015 Views

Perl 语言编程 - Linux教程

Perl 语言编程 - Linux教程

Perl 语言编程 - Linux教程

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

# 制 作 远 端 机 器 的 地 址$internet_addr = inet_aton($remote_host)or die "Couldn't convert $remote_host into an Internet address: $!\n";$paddr = sockaddr_in($remote_port, $internet_addr);# 联 接connect(Server, $paddr)or die "Couldn't connect to $remote_host:$remote_port: $!\n";select((select(Server), $| = 1)[0]);# 打 开 命 令 缓 冲# 通 过 套 接 字 发 送 一 些 东 西print Server "Why don't you call me anymore?\n";# 读 取 远 端 的 响 应$answer = ;# 处 理 完 之 后 终 止 联 接close(Server);如 果 你 想 只 关 闭 你 方 的 联 接 , 这 样 远 端 就 可 以 得 到 一 个 end-of-file, 不 过 你 还 是 能 够 读 取来 自 该 服 务 器 的 数 据 , 使 用 shutdown 系 统 调 用 进 行 半 关 闭 :# 不 再 向 服 务 器 写 数 据shutdown(Server, 1);# 在 v5.6 里 的 Socket::SHUT_WR 常 量445

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!