Skip to content

Commit a1ce15f

Browse files
committed
Adding missing protocols from libzmq, in the same order.
1 parent 2b4d2ce commit a1ce15f

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/main/java/zmq/io/net/NetProtocol.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
public enum NetProtocol
2929
{
3030
inproc(false, false),
31-
ipc(false, false)
31+
tcp(false, false)
3232
{
3333
@Override
3434
public void resolve(Address paddr, boolean ipv6)
3535
{
3636
paddr.resolve(ipv6);
3737
}
3838
},
39-
tcp(false, false)
39+
udp(true, true)
4040
{
4141
@Override
4242
public void resolve(Address paddr, boolean ipv6)
@@ -48,6 +48,17 @@ public void resolve(Address paddr, boolean ipv6)
4848
// sent to this pipe. (same for NORM, currently?)
4949
pgm(true, true, Sockets.PUB, Sockets.SUB, Sockets.XPUB, Sockets.XPUB),
5050
epgm(true, true, Sockets.PUB, Sockets.SUB, Sockets.XPUB, Sockets.XPUB),
51+
norm(true, true),
52+
ws(true, true),
53+
wss(true, true),
54+
ipc(false, false)
55+
{
56+
@Override
57+
public void resolve(Address paddr, boolean ipv6)
58+
{
59+
paddr.resolve(ipv6);
60+
}
61+
},
5162
tipc(false, false)
5263
{
5364
@Override
@@ -56,7 +67,7 @@ public void resolve(Address paddr, boolean ipv6)
5667
paddr.resolve(ipv6);
5768
}
5869
},
59-
norm(true, true),
70+
vmci(true, true),
6071
;
6172

6273
private static final Map<NetProtocol,NetworkProtocolProvider > providers;
@@ -75,13 +86,13 @@ public void resolve(Address paddr, boolean ipv6)
7586
public final boolean isMulticast;
7687
private final Set<Integer> compatibles;
7788

78-
private NetProtocol(boolean subscribe2all, boolean isMulticast, Sockets... compatibles)
89+
NetProtocol(boolean subscribe2all, boolean isMulticast, Sockets... compatibles)
7990
{
8091
this.compatibles = Arrays.stream(compatibles).map(Sockets::ordinal).collect(Collectors.toSet());
8192
this.subscribe2all = subscribe2all;
8293
this.isMulticast = isMulticast;
8394
}
84-
95+
8596
public boolean isValid() {
8697
return providers.containsKey(this) && providers.get(this).isValid();
8798
}

src/main/java/zmq/io/net/NetworkProtocolProvider.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313

1414
public interface NetworkProtocolProvider {
1515
boolean handleProtocol(NetProtocol protocol);
16-
public Listener getListener(IOThread ioThread, SocketBase socket,
17-
Options options);
18-
public IZAddress zresolve(String addr, boolean ipv6);
19-
public abstract void startConnecting(Options options, IOThread ioThread, SessionBase session, Address addr,
20-
boolean delayedStart, Consumer<Own> launchChild, BiConsumer<SessionBase, IEngine> sendAttach);
16+
Listener getListener(IOThread ioThread, SocketBase socket, Options options);
17+
IZAddress zresolve(String addr, boolean ipv6);
18+
void startConnecting(Options options, IOThread ioThread, SessionBase session, Address addr, boolean delayedStart,
19+
Consumer<Own> launchChild, BiConsumer<SessionBase, IEngine> sendAttach);
2120
boolean isValid();
2221

2322
}

src/main/java/zmq/io/net/tcp/TcpConnecter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,13 @@ private void startConnecting()
176176
try {
177177
boolean rc = open();
178178

179+
handle = ioObject.addFd(fd);
179180
// Connect may succeed in synchronous manner.
180181
if (rc) {
181-
handle = ioObject.addFd(fd);
182182
connectEvent();
183183
}
184184
// Connection establishment may be delayed. Poll for its completion.
185185
else {
186-
handle = ioObject.addFd(fd);
187186
ioObject.setPollConnect(handle);
188187
socket.eventConnectDelayed(addr.toString(), -1);
189188
}
@@ -295,10 +294,7 @@ private boolean open() throws IOException
295294
boolean rc;
296295
try {
297296
rc = fd.connect(sa);
298-
if (rc) {
299-
// Connect was successful immediately.
300-
}
301-
else {
297+
if (! rc) {
302298
// Translate error codes indicating asynchronous connect has been
303299
// launched to a uniform EINPROGRESS.
304300
errno.set(ZError.EINPROGRESS);

0 commit comments

Comments
 (0)