我在this is server output when message received from android app
以下是Android代码 android code for sending message
现在,发送消息且我的代码在以下时,ios端this中的服务器输出:
let client = TCPClient(address: "172.20.10.4", port: 1333)
switch client.connect(timeout: 20) {
case .success:
print("Connected to Server")
let string = "GETNEWGAMEBOOKING"
// let data = Array(string.utf8)
let data = string.data(using: .utf8)!
switch client.send(data: data){
case .success:
guard let data = client.read(1024*10) else { return }
print(data)
let strResponse = String(data: Data(data), encoding: .utf8)
print(strResponse!)
if let response = String(bytes: data, encoding: .utf8) {
print(response)
}
break;
case .failure(let err):
print(err.localizedDescription)
break;
}
case .failure(let error):
print(error)
}
我的问题是在android输出上如何在消息中添加这4个字节?
我正在为此项目使用“ SwiftSocket”。