memScoped {
val serverAddress = alloc<sockaddr_in>()
serverAddress.sin_family = AF_INET.toShort()
serverAddress.sin_port = htons(15583)
serverAddress.sin_addr.s_addr = inet_addr("0.0.0.0")
for this code getting an error :Unresolved reference: s_addr
Import the below reference
import kotlinx.cinterop.*
import platform.posix.*
import platform.windows.htonl
import kotlin.native.concurrent.*
One thin I was found that if write code like
serverAddress.sin_addr.S_un.S_addr = inet_addr("0.0.0.0")
then no issue was found but it fails at bind method
if (bind(serverSocket, serverAddress.ptr.reinterpret(), sizeOf<sockaddr_in>().convert()) < 0) {
perror("server: can't bind local address")
return
}
Return the error. can't bind local address.