Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.swift
- // BotDofus
- //
- // Created by Christopher Yovanovitch on 25/04/2017.
- // Copyright © 2017 Christopher Yovanovitch. All rights reserved.
- //
- import UIKit
- class ViewController: UIViewController {
- let host = "213.248.126.39"
- let port = 5555
- var client: TCPClient?
- override func viewDidLoad() {
- super.viewDidLoad()
- client = TCPClient(address: host, port: Int32(port))
- guard let client = client else { return }
- switch client.connect(timeout: 10) {
- case .success:
- print("🎉 Connected! 🎉")
- if let data = client.read(1024 * 10) {
- print(data.debugDescription)
- } else {
- print("error..")
- }
- // switch client.send(data: [1, 2, 3]) {
- // case .success:
- // print("Successfully send data..")
- // guard let data = client.read(1024 * 10) else { return }
- //
- // if let response = String(bytes: data, encoding: .utf8) {
- // print(response)
- // }
- // case .failure(let error):
- // print("💩: \(error.localizedDescription)")
- // }
- break
- case .failure(let error):
- print("💩: \(error.localizedDescription)")
- break
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement