B

Bimmel

Mitglied

Zuletzt aktiv vor 3 Wochen

  1. vor 3 Wochen
    j M Y, g:ia \G\M\TO
    B Bimmel beginnt die Unterhaltung TCP-Client receiving error.

    Hey!

    I tried programming simple TCP-Clients using SwiftSocket and CocoaAsyncSocket. Both are connecting to the server, and both are sending messages, but neither SwiftSocket nor CocoaAsyncSocket are able to receive messages. Xcode just prints out "-1" after connecting to the server. As a Server I tried several Socket-Test Applications and a simple Echo-Server running on an Arduino.

    My Code for SwiftSocket looks like this :

    let client = TCPClient(address: "192.168.178.23", port: 8000)
            switch client.connect(timeout: 1) {
            case .success:
                
                switch client.send(string: "hey" ) {
                case .success:
                    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)
                }
     
                
                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)
            }
     

    (It's just the example from the Github side)

    Do I have a general Problem with my Network setup (since Both Libraries have the same error) or am I missing something else?

    I hope you can help me with that!

  2. j M Y, g:ia \G\M\TO
    B Bimmel ist dem Forum beigetreten.