Skip to content

Commit

Permalink
Replace SO_REUSEADDR with SO_REUSEPORT in Unix socket settings
Browse files Browse the repository at this point in the history
The commit updates the Unix socket settings function from using the SO_REUSEADDR option to the SO_REUSEPORT option. This change is made in the `util_unix.go` file. SO_REUSEPORT is preferable as it permits multiple sockets to be bound to an identical socket address.
  • Loading branch information
ryanbekhen committed Feb 14, 2024
1 parent 27dafcc commit e7a9747
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

package sfu

import (
"golang.org/x/sys/unix"
"syscall"
)

func setSocketOptions(network, address string, conn syscall.RawConn) error {
var operr error
if err := conn.Control(func(fd uintptr) {
operr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
operr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1)
}); err != nil {
return err
}
Expand Down

0 comments on commit e7a9747

Please sign in to comment.