🔌 Non-blocking TCP socket layer, with event-driven server and client.

Overview
Comments
  • swift build error on armv7l debian

    swift build error on armv7l debian

    in trying to add your library as a swift package, i cannot successfully $ swift build. i'm not sure if this is an issue due to the architecture i'm using, or if i'm doing something else completely innane. in any case, just wanted to report it. thanks in advance for any assistance!

    -- mack

    here is the output: [email protected]:~/macks-projects/blink/blink-package/Sources# swift build Compile Swift Module 'SocksCore' (14 sources) /root/macks-projects/blink/blink-package/Packages/Socks-0.7.0/Sources/SocksCore/FDSet.swift:34:20: error: cannot assign value of type '(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)' to type '(__fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask)' (aka '(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)') set.__fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <unknown>:0: error: build had 1 command failures error: exit(1): /root/macks-projects/pre-built-swift/swift-3.0/usr/bin/swift-build-tool -f /root/macks-projects/blink/blink-package/.build/debug.yaml

    opened by mackhowell 7
  • Failure to compile on Raspberry Pi

    Failure to compile on Raspberry Pi

    FD_ZERO is apparently defined as 32 bytes on an R/Pi 3:

    uname -a
    Linux ubuntu 4.4.0-1029-raspi2 #36-Ubuntu SMP Wed Oct 19 14:38:48 UTC 2016 armv7l armv7l armv7l GNU/Linux
    

    I get the following compile error on an R/Pi 3 running latest version of ubuntu:

    swift build
    Cloning https://github.com/czechboy0/Redbird.git
    HEAD is now at bb2ac0e Updated Swift to 08-15 (#38)
    Resolved version: 0.10.0
    Cloning https://github.com/czechboy0/Socks.git
    HEAD is now at 460dc7f Merge pull request #73 from vapor/gm
    Resolved version: 0.12.2
    Compile Swift Module 'SocksCore' (14 sources)
    /home/ubuntu/BlueCycles/linux/Packages/Socks-0.12.2/Sources/SocksCore/FDSet.swift:34:20: error: cannot assign value of type '(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)' to type '(__fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask, __fd_mask)' (aka '(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)')
      set.__fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <unknown>:0: error: build had 1 command failures
    error: exit(1): /usr/bin/swift-build-tool -f /home/ubuntu/BlueCycles/linux/.build/debug.yaml
    
    opened by rvsrvs 6
  • rare `UnsafeMutablePointer.initializeFrom` error

    rare `UnsafeMutablePointer.initializeFrom` error

        let _raw: UnsafeMutablePointer<sockaddr_storage>
        var raw: UnsafeMutablePointer<sockaddr> {
            return UnsafeMutablePointer<sockaddr>(_raw)
        }
    
        init(raw: UnsafeMutablePointer<sockaddr_storage>) {
            let ptr = UnsafeMutablePointer<sockaddr_storage>.init(allocatingCapacity: 1)
            >>>>>> ptr.initializeFrom(raw, count: 1)
            self._raw = ptr
        }
    
    fatal error: UnsafeMutablePointer.initializeFrom non-following overlapping range
    

    This happens every once in a while. I can't reproduce, but putting it here in case anyone finds more information about it.

    bug 
    opened by tanner0101 6
  • add several podspec for CocoaPods support

    add several podspec for CocoaPods support

    it's make me feel sad that I can't use this library directly in my iOS App with swiftpm, so I have create several podspec files, make it's easy to use this lib in their CocoaPods project.

    opened by codetalks-new 5
  • Cocoapods support

    Cocoapods support

    Hello there! You library is awesome but it's hard to use it in big iOS project without dependency manager support. Do you have plans to add Cocoapods support?

    opened by danshevluk 5
  • add readn func to TCPReadableSocket

    add readn func to TCPReadableSocket

    as TCP is a stream protocol, At many times, one data packet may be send within different segment. so a readn func would help us a lot. advices need to improve it.

    opened by codetalks-new 5
  • Various improvements

    Various improvements

    Improved performance

    Previously, all bytes received were passed trough an map operation that is not required, since the bytes are already UInt8. This change improves performance for large transfers considerably.

    Improves https://github.com/vapor/vapor/issues/734

    Improved cleanup and safety

    • TCPInternetSocket and UDPInternetSocket now close their descriptors on deinit
    • Additional calls to close() don't try to close the file descriptor anymore
    • Attempts to use a closed TCPInternetSocket or UDPInternetSocket now throw to prevent using a descriptor that may already be used otherwise

    Improved testing

    • WatchingTests are now run under Linux, too
    • WatchingTests should not fail anymore
    • Added tests for releasing and using closed sockets
    opened by andreasley 5
  • Socks times out when receiving all data where the `messagedata.count % 512 == 0`

    Socks times out when receiving all data where the `messagedata.count % 512 == 0`

    extension TCPReadableSocket {
    
        public func recv(maxBytes: Int = BufferCapacity) throws -> [UInt8] {
            let data = Bytes(capacity: maxBytes)
            let flags: Int32 = 0 //FIXME: allow setting flags with a Swift enum
            let receivedBytes = socket_recv(self.descriptor, data.rawBytes, data.capacity, flags)
            guard receivedBytes > -1 else { throw SocksError(.readFailed) }
            let finalBytes = data.characters[0..<receivedBytes]
            let out = Array(finalBytes.map({ UInt8($0) }))
            return out
        }
    
        public func recvAll() throws -> [UInt8] {
            var buffer: [UInt8] = []
            let chunkSize = 512
            while true {
                let newData = try self.recv(maxBytes: chunkSize)
                buffer.append(contentsOf: newData)
                if newData.count < chunkSize {
                    break
                }
            }
            return buffer
        }
    }
    

    Here at the line if newData.count < chunkSize every user will get a timeout when the last chunk received (newData) has a count of 512 bytes. This has been haunting us for days until we realised the socket library might be at fault.

    opened by Joannis 5
  • WebSocket and Socks

    WebSocket and Socks

    So I've started up a TCP server with socks and a TCP Client with straight Javascript.

    I get the initial request from my javascript client to my Socks server, but however I have no idea what to send back to the javascript client to allow it to upgrade and begin sending and receiving data. I've had this issue with various WebSocket clients of not being able to complete the connection...

    In Socks what should I do? my server is basically the sample code you've provided, and the client is the sample code provided here: http://www.tutorialspoint.com/html5/html5_websocket.htm

    ironically, I do get the disconnect message when I turn off my server.

    I also tried using the Socks TCPSocket Client and I get roughly the same issue, I can send the first message, and then nothing works after that.

    opened by PhilipHayes 5
  • Send/receive timeouts

    Send/receive timeouts

    Added sending and receiving timeout options to SocketOptions. This allows callers to specify timeouts on a socket. Please note that 0 timeout means wait forever, not return immediately, so be careful when integrating with other libraries, some use -1 as wait forever, which is an invalid value here.

    /cc @tannernelson

    Fixes #30, #48

    opened by czechboy0 4
  • Response not received

    Response not received

    In iOS mobile app, when mobile/cellular data and WiFi connections - both are Enabled and App tries to perform socket operation on WiFi connected device, app able to create connection and send data successfully but it does not able to receive response and throws exception: "The operation couldn’t be completed. (appName.SocketsError error 1.)"

    opened by kartikpatel211 3
  • Build fails when standalone

    Build fails when standalone

    The swift build fails with Fatal error: Duplicate values for key: 'Async': file /BuildRoot/Library/Caches/com.apple.xbs/Binaries/swiftlang/install/TempContent/Objects/BNI_assert_lightweight/swift-macosx-x86_64/stdlib/public/core/8/HashedCollections.swift, line 8108

    The complete output is this: Fetching https://github.com/vapor/core.git Fetching https://github.com/vapor/async.git Fetching https://github.com/apple/swift-nio.git Fetching https://github.com/apple/swift-nio-zlib-support.git Cloning https://github.com/apple/swift-nio.git Resolving https://github.com/apple/swift-nio.git at 1.9.2 Cloning https://github.com/vapor/async.git Resolving https://github.com/vapor/async.git at 1.0.0-rc.1.1 Cloning https://github.com/vapor/core.git Resolving https://github.com/vapor/core.git at 3.4.1 Cloning https://github.com/apple/swift-nio-zlib-support.git Resolving https://github.com/apple/swift-nio-zlib-support.git at 1.0.0 Fatal error: Duplicate values for key: 'Async': file /BuildRoot/Library/Caches/com.apple.xbs/Binaries/swiftlang/install/TempContent/Objects/BNI_assert_lightweight/swift-macosx-x86_64/stdlib/public/core/8/HashedCollections.swift, line 8108 Illegal instruction: 4 I was trying to investigate why swift package update was stuck on this dependency of vapor.

    opened by eutampieri 1
Releases(2.2.3)
Owner
Vapor Community
Packages maintained by Vapor's community members.
Vapor Community
A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework

Serverside non-blocking IO in Swift Ask questions in our Slack channel! Lightning (formerly Edge) Node Lightning is an HTTP Server and TCP Client/Serv

SkyLab 316 Aug 4, 2022
An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps

PeerKit An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps Usage // Automatically detect and attach to

JP Simard 860 Sep 2, 2022
Socket.io iOS and OSX Client compatible with v1.0 and later

SocketIO-Kit ⚠️ This project is no longer maintained. Please use the official framework Socket.IO-Client-Swift. SocketIO-Kit is a Socket.io iOS client

Ricardo Pereira 140 Mar 9, 2022
Menet is a TCP network middleware that can be dynamically modified through HTTP requests.

Menet Menet is a TCP network middleware that can be dynamically modified through HTTP requests. This is an experimental project, do NOT use it in prod

Nik 2 May 19, 2022
Passepartout is a non-official, user-friendly OpenVPN® client for iOS and macOS.

Passepartout Passepartout is a non-official, user-friendly OpenVPN® client for iOS and macOS. Overview All profiles in one place Passepartout lets you

Passepartout 472 Sep 15, 2022
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.

BlueSocket Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux. Prerequisites Swift Swift Open Source swift-5.1

Kitura 1.3k Sep 21, 2022
Asynchronous socket networking library for Mac and iOS

CocoaAsyncSocket CocoaAsyncSocket provides easy-to-use and powerful asynchronous socket libraries for macOS, iOS, and tvOS. The classes are described

Robbie Hanson 12.3k Sep 25, 2022
DispatchSource based socket framework written in pure Swift

SwiftDSSocket Overview SwiftDSSocket is a purely swift based asynchronous socket framework built atop DispatchSource. Function signatures are pretty m

Yi Huang 64 Apr 24, 2022
MVVM project to show AQI of cities via web socket

Air Quality Monitoring Application Swift project with JSON parsing using codable About the application The app consists of live realtime data from the

Pran Kishore 0 Nov 27, 2021
This app is using web-socket for realtime updation of aqi for dedicated inidan cities.

CityWiseAQI This app is using web-socket for realtime updation of aqi for dedicated inidan cities. We're following MVVM architecture in this app. This

Vipul Kumar 2 Feb 7, 2022
Swift async/await based socket

Socket Swift async/await based socket library Introduction This library exposes an idiomatic Swift API for interacting with POSIX sockets via an async

null 57 Aug 15, 2022
A simple GCD based HTTP client and server, written in 'pure' Swift

SwiftyHTTP Note: I'm probably not going to update this any further - If you need a Swift networking toolset for the server side, consider: Macro.swift

Always Right Institute 116 Aug 6, 2022
WebSocket implementation for use by Client and Server

WebSocket ⚠️ This module contains no networking. To create a WebSocket Server, see WebSocketServer. To create a WebSocket Client, see WebSocketClient.

Zewo Graveyard 63 Jan 29, 2022
Minecraft server RCON client for iOS/macOS

iRCON Minecraft server RCON client for iOS/macOS. Features Full remote console window Player list with ability to easily op, kick, ban, etc. Quickly s

JackMacWindows 8 Aug 8, 2022
Language Server Protocol (LSP) client for Swift

LanguageClient This is a Swift library for abstracting and interacting with language servers that implement the Language Server Protocol. It is built

Chime 27 Sep 14, 2022
A computer-vision-driven app for detecting and mapping smog in public roads. Crowdsourcing is rewarded with NFTs. Uber Global Hackathon.

Smogify Detecting smog using ML and rewarding users with NFTs About The Project app in action: https://youtu.be/awJrP-sHb_I Under the growing uncertai

ASOFI 3 Aug 18, 2022
NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. ⚙️🚀

SONetworking NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. Project Folder and File Struc

Ahmad AlSofi 4 Jan 28, 2022
Twitter-Client - A twitter client that allow users to view tweets on their iphone

Project 3 - Twitter Client Name of your app is a basic twitter app to read your

null 0 Feb 7, 2022
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Ronan Rodrigo Nunes 87 Jan 21, 2022