Swift Socket 封装库 SwiftSockets

码农软件 · 软件分类 · 网络工具包 · 2019-02-27 10:14:19

软件介绍

SwiftSockets 是一个简单的 Swift Socket 封装库。

服务器端:

let socket = PassiveSocket(address: sockaddr_in(port: 4242))
socket.listen(dispatch_get_global_queue(0, 0), backlog: 5) {
  println("Wait, someone is attempting to talk to me!")
  $0.close()
  println("All good, go ahead!")
}

客户端:

let socket = ActiveSocket().onRead {
  let (count, block, errno) = $0.read()
  if count < 1 {
    println("EOF, or great error handling \(errno).")
    return
  }
  println("Answer to ring,ring is: \(count) bytes: \(block)")
}
socket.connect("127.0.0.1:80") {
  socket.write("Ring, ring!\r\n")
}

本文地址:https://www.codercto.com/soft/d/233.html

The Art of Computer Programming, Volume 2

The Art of Computer Programming, Volume 2

Knuth, Donald E. / Addison-Wesley Professional / 1997-11-04 / USD 79.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 2》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器