- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 23.5k
 
          Expose SO_REUSEADDR and SO_REUSEPORT socket options to PacketPeerUDP
          #112305
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -547,10 +547,18 @@ void NetSocketWinSock::set_tcp_no_delay_enabled(bool p_enabled) { | |
| } | ||
| 
     | 
||
| void NetSocketWinSock::set_reuse_address_enabled(bool p_enabled) { | ||
| ERR_FAIL_COND(!is_open()); | ||
| ERR_FAIL_COND(_sock == INVALID_SOCKET); | ||
| 
     | 
||
| int par = p_enabled ? 1 : 0; | ||
| if (setsockopt(_sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&par, sizeof(int)) < 0) { | ||
| WARN_PRINT("Unable to set socket REUSEADDR option."); | ||
| } | ||
| } | ||
| 
         
      Comment on lines
    
      +552
     to 
      +556
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 Since it was deliberately disabled and  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. From doing a global search in the code base. The only times  From my research I don't believe it would cause any issues with existing behavior. Then again i try to stay away from Windows as a whole, so im no expert. Ill push a new commit that moves the logic into   | 
||
| 
     | 
||
| void NetSocketWinSock::set_reuse_port_enabled(bool p_enabled) { | ||
| ERR_FAIL_COND(_sock == INVALID_SOCKET); | ||
| 
     | 
||
| // On Windows, enabling SO_REUSEADDR actually would also enable reuse port, very bad on TCP. Denying... | ||
| // Windows does not have this option, SO_REUSEADDR in this magical world means SO_REUSEPORT | ||
| // SO_REUSEPORT is not supported on windows, as its features are implemented as part of SO_REUSEADDR | ||
| } | ||
| 
     | 
||
| bool NetSocketWinSock::is_open() const { | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it supported on every other platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on MacOS and Linux. In theory IOS and Android should work, however they may need some permission set. Then again due to the nature of mobile oprating system, it would be unlikely you would be able / need to run 2 instances of the same godot project at the same time