Kitura / Kitura/BlueSocket

multi-process problem

Open
#63 13 comments 0 reactions 1 assignee Claimed by @adam-rocska View on GitHub
Dominant language
Swift
Stars
1.4k
Forks
193
PR merge metrics
No merged PRs in 30d

Description

When I use this library to integrate into Linux multi-process swift code, it occurs a fatal error while call the acceptClientConnection method, error message is : -9994(0x-270A), Invalid argument

the code is below:
```
do {
var socket: Socket? = try Socket.create()

guard let listenSocket = socket else {
print("unable to create socket...")
exit(-1)
}

var isRunning = true
try listenSocket.listen(on: 6666)

repeat {
print(listenSocket.signature?.description)
let connectSocket = try listenSocket.acceptClientConnection()
print("Accepted connection from: \(connectSocket.remoteHostname) on port \(connectSocket.remotePort)")
//print("Socket Signature: \(connectSocket.signature?.description)")

var childpid = fork()

if childpid == -1 {
print("fork failed")
exit(-1)
} else if childpid > 0 {
print("parent process")
connectSocket.close()
isRunning = true
} else {
print("child process")
listenSocket.close()
handleReqeust(connectSocket)
isRunning = false
}


} while isRunning


} catch let error {
guard let socketError = error as? Socket.Error else {
print("unknown error...")
exit(-1)
}
print("Error reported:\n \(socketError.description)")

}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.