Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion header.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2012-2025 Nikita Koksharov
Copyright (c) 2025 The Socketio4j Project
Parent project : Copyright (c) 2012-2025 Nikita Koksharov

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,10 +16,12 @@
*/
package com.corundumstudio.socketio;


import java.util.Arrays;
import java.util.List;

import com.corundumstudio.socketio.nativeio.TransportType;


/**
* Basic configuration class, contains only primitive, String and enum types
* as fields. Used as a base class for Configuration
Expand All @@ -31,10 +34,9 @@ public abstract class BasicConfiguration {

protected int bossThreads = 0; // 0 = current_processors_amount * 2
protected int workerThreads = 0; // 0 = current_processors_amount * 2
protected boolean useLinuxNativeEpoll;
protected boolean useLinuxNativeIoUring;

protected boolean useUnixNativeKqueue;
protected TransportType transportType = TransportType.AUTO;

protected boolean allowCustomRequests = false;

protected int upgradeTimeout = 10000;
Expand Down Expand Up @@ -75,9 +77,7 @@ protected BasicConfiguration() {
protected BasicConfiguration(BasicConfiguration conf) {
setBossThreads(conf.getBossThreads());
setWorkerThreads(conf.getWorkerThreads());
setUseLinuxNativeEpoll(conf.isUseLinuxNativeEpoll());
setUseLinuxNativeIoUring(conf.isUseLinuxNativeIoUring());
setUseUnixNativeKqueue(conf.isUseUnixNativeKqueue());
setTransportType(conf.getTransportType());
setPingInterval(conf.getPingInterval());
setPingTimeout(conf.getPingTimeout());
setFirstDataTimeout(conf.getFirstDataTimeout());
Expand Down Expand Up @@ -353,29 +353,14 @@ public boolean isEnableCors() {
return enableCors;
}

public boolean isUseLinuxNativeEpoll() {
return useLinuxNativeEpoll;
public TransportType getTransportType() {
return transportType;
}

public void setUseLinuxNativeEpoll(boolean useLinuxNativeEpoll) {
this.useLinuxNativeEpoll = useLinuxNativeEpoll;
public void setTransportType(TransportType transportType) {
this.transportType = transportType;
}

public boolean isUseLinuxNativeIoUring() {
return useLinuxNativeIoUring;
}

public void setUseLinuxNativeIoUring(boolean useLinuxNativeIoUring) {
this.useLinuxNativeIoUring = useLinuxNativeIoUring;
}

public boolean isUseUnixNativeKqueue() {
return useUnixNativeKqueue;
}

public void setUseUnixNativeKqueue(boolean useUnixNativeKqueue) {
this.useUnixNativeKqueue = useUnixNativeKqueue;
}
/**
* Set the response Access-Control-Allow-Headers
*
Expand Down Expand Up @@ -461,50 +446,4 @@ public boolean isNeedClientAuth() {
return needClientAuth;
}

/**
* Validates the native transport configuration.
* <p>
* Only one native transport may be enabled at a time. The supported native
* transports are:
* <ul>
* <li>io_uring (Linux)</li>
* <li>epoll (Linux)</li>
* <li>kqueue (macOS / BSD)</li>
* </ul>
* <p>
* This method performs a bitmask-based check to ensure that at most one of the
* transport flags is enabled. If more than one flag is set, an
* {@link IllegalArgumentException} is thrown detailing which transports were
* simultaneously enabled.
*
* @throws IllegalArgumentException
* if more than one native transport is configured at the same time
*/
public void validate() {
int bits = 0;
if (isUseLinuxNativeIoUring()) bits |= 1;
if (isUseLinuxNativeEpoll()) bits |= 2;
if (isUseUnixNativeKqueue()) bits |= 4;

if (Integer.bitCount(bits) > 1) {
throw new IllegalArgumentException(
"Only one native transport MUST be enabled: " + enabledTransports(bits)
);
}
}


private String enabledTransports(int bits) {
StringBuilder sb = new StringBuilder();

sb.append("[");
if ((bits & 1) != 0) sb.append("io_uring ");
if ((bits & 2) != 0) sb.append("epoll ");
if ((bits & 4) != 0) sb.append("kqueue ");
sb.append("]");

return sb.toString().trim();
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
* Copyright (c) 2025 The Socketio4j Project
* Parent project : Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading