You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var address = sockaddr_in6()
#if !os(Linux)
address.sin6_len = UInt8(MemoryLayout<sockaddr_in6>.stride)
#endif
address.sin6_family = sa_family_t(AF_INET6)
address.sin6_port = UInt16(port).bigEndian //This basically I think Cause error
address.sin6_flowinfo = 0
address.sin6_addr = try ipAddressToStruct(address: interface)
address.sin6_scope_id = 0
let size = socklen_t(MemoryLayout<sockaddr_in6>.size)
// bind the address and port on socket
guard withUnsafePointer(to: &address, { pointer in
return pointer.withMemoryRebound(to: sockaddr.self, capacity: Int(size)) { pointer in
return SystemLibrary.bind(fileDescriptor, pointer, size) >= 0
}
}) else {
throw OSError.lastIOError()
}
This part of the code is throwing the error. Error number 1 and error description "Operation Not Permitted". I am new to swift and trying to implement mock server on the ongoing project. Can someone have answer for this?
The text was updated successfully, but these errors were encountered:
@srijanraj What's the port number you are binding to? As far as I know, if you are binding to port numbers which are below 1024 or a certain number, say you're binding port 80, it will usually require root permission to do so. I guess that's why you are seeing Operation Not Permitted error. If it's the case, I would suggest to use port numbers like 8080 or any number you like that's higher than 1024
I set port 8880 and I got the same issue, when I create severer from main app target it's okay, but when I try start server from uitests target for macOS app (for iOS it works) then I got same issue:
Embassy.OSError.ioError(number: 1, message: "Operation not permitted")
var address = sockaddr_in6()
#if !os(Linux)
address.sin6_len = UInt8(MemoryLayout<sockaddr_in6>.stride)
#endif
address.sin6_family = sa_family_t(AF_INET6)
address.sin6_port = UInt16(port).bigEndian //This basically I think Cause error
address.sin6_flowinfo = 0
address.sin6_addr = try ipAddressToStruct(address: interface)
address.sin6_scope_id = 0
let size = socklen_t(MemoryLayout<sockaddr_in6>.size)
// bind the address and port on socket
guard withUnsafePointer(to: &address, { pointer in
return pointer.withMemoryRebound(to: sockaddr.self, capacity: Int(size)) { pointer in
return SystemLibrary.bind(fileDescriptor, pointer, size) >= 0
}
}) else {
throw OSError.lastIOError()
}
This part of the code is throwing the error. Error number 1 and error description "Operation Not Permitted". I am new to swift and trying to implement mock server on the ongoing project. Can someone have answer for this?
The text was updated successfully, but these errors were encountered: