GithubHelp home page GithubHelp logo

hulk10425 / tcp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zewograveyard/tcp

0.0 2.0 0.0 86 KB

CSP (coroutine) based Swift TCP sockets for macOS and Linux

License: MIT License

Swift 100.00%

tcp's Introduction

TCP

Swift License Slack Travis Codecov Codebeat

Features

  • TCPConnection
  • TCPServer

##Usage

co {
    do {
        // create an echo server on localhost:8080
        let server = try TCPServer(host: "127.0.0.1", port: 8080)
        while true {
            // waits for an incoming connection, receives 1024 bytes, sends them back
            let connection = try server.accept()
            let data = try connection.receive(upTo: 1024)
            try connection.send(data)
        }
    } catch {
        print(error)
    }
}

nap(for: 100.milliseconds)

// create a connection to server at localhost:8080
let connection = try TCPConnection(host: "0.0.0.0", port: 8080)
// opens the connection, sends "hello"
try connection.open()
try connection.send("hello")
// waits for a message, prints it out
let data =  try connection.receive(upTo: 1024)
print(data)

Installation

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/VeniceX/Zewo.git", majorVersion: 0, minor: 14)
    ]
)

Support

If you need any help you can join our Slack and go to the #help channel. Or you can create a Github issue in our main repository. When stating your issue be sure to add enough details, specify what module is causing the problem and reproduction steps.

Community

Slack

The entire Zewo code base is licensed under MIT. By contributing to Zewo you are contributing to an open and engaged community of brilliant Swift programmers. Join us on Slack to get to know us!

License

This project is released under the MIT license. See LICENSE for details.

tcp's People

Contributors

scottbyrns avatar paulofaria avatar antonmes avatar czechboy0 avatar dreymonde avatar robertjpayne avatar tomohisa avatar danappelxx avatar davidask avatar hulk10425 avatar bosr avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.