mbien commented on PR #7776:
URL: https://github.com/apache/netbeans/pull/7776#issuecomment-2367914882

   > Occupied socket by another instance of the same program cannot be solved 
by any if. 
   
   It might be different now but the first two semesters were essentially tasks 
like: "Pass a long between two processes and implement it in 1-3 languages (or 
stick to java but write one for corba, sockets and RMI)."
   
   ```java
       public void main() throws IOException {
   
           Path socketFile = Path.of("/tmp/connector");
   
           long myPid = ProcessHandle.current().pid();
           System.out.println("my pid "+myPid);
   
           UnixDomainSocketAddress address = 
UnixDomainSocketAddress.of(socketFile);
   
           ByteBuffer bb = ByteBuffer.allocate(8);
           if (Files.notExists(socketFile)) {
               try (ServerSocketChannel server = 
ServerSocketChannel.open(StandardProtocolFamily.UNIX)) {
                   server.bind(address);
                   try (SocketChannel channel = server.accept()) {
                       bb.putLong(0, myPid);
                       channel.write(bb);
                   }
               }
           } else {
               try (SocketChannel channel = 
SocketChannel.open(StandardProtocolFamily.UNIX)) {
                   channel.connect(address);
                   channel.read(bb);
                   System.out.println("other program pid: "+bb.getLong(0));
               }
               Files.delete(socketFile);
           }
       }
   ```
   
   It might no longer be common, but I don't think an IDE should prohibit to 
run things like that due to extra process-cancel magic. I think once the 
toolbar is there and other UX features are implemented it all will "fall into 
place" and make sense for newbies. The cancel-other feature might still be 
useful as toggle action on a toolbar - but I don't think it should be the 
default.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to