Skip to content

Commit

Permalink
sockets: udp refactoring (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Jan 10, 2024
1 parent b703b28 commit e6325fa
Show file tree
Hide file tree
Showing 6 changed files with 507 additions and 840 deletions.
2 changes: 0 additions & 2 deletions packages/preview2-shim/lib/io/calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ export const SOCKET_UDP_RECEIVE = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_DISPOSE = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_GET_LOCAL_ADDRESS = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_GET_REMOTE_ADDRESS = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_GET_RECEIVE_BUFFER_SIZE = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_SET_RECEIVE_BUFFER_SIZE = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_GET_SEND_BUFFER_SIZE = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_SET_SEND_BUFFER_SIZE = ++call_id << CALL_SHIFT;
export const SOCKET_UDP_SET_UNICAST_HOP_LIMIT = ++call_id << CALL_SHIFT;
// Name lookup
Expand Down
21 changes: 1 addition & 20 deletions packages/preview2-shim/lib/io/worker-thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ import {
SOCKET_UDP_DISCONNECT,
SOCKET_UDP_DISPOSE,
SOCKET_UDP_GET_LOCAL_ADDRESS,
SOCKET_UDP_GET_RECEIVE_BUFFER_SIZE,
SOCKET_UDP_GET_REMOTE_ADDRESS,
SOCKET_UDP_GET_SEND_BUFFER_SIZE,
SOCKET_UDP_RECEIVE,
SOCKET_UDP_SEND,
SOCKET_UDP_SET_RECEIVE_BUFFER_SIZE,
Expand Down Expand Up @@ -331,8 +329,7 @@ function handle(call, id, payload) {

// Sockets UDP
case SOCKET_UDP_CREATE_HANDLE: {
const { addressFamily, reuseAddr } = payload;
return createUdpSocket(addressFamily, reuseAddr);
return createUdpSocket(payload, null);
}
case SOCKET_UDP_BIND:
return socketUdpBind(id, payload);
Expand All @@ -358,14 +355,6 @@ function handle(call, id, payload) {
addr.family = addr.family.toLowerCase();
return addr;
}
case SOCKET_UDP_GET_RECEIVE_BUFFER_SIZE: {
const socket = getUdpSocketOrThrow(id);
try {
return BigInt(socket.getRecvBufferSize());
} catch (err) {
throw convertSocketError(err);
}
}
case SOCKET_UDP_SET_RECEIVE_BUFFER_SIZE: {
const socket = getUdpSocketOrThrow(id);
try {
Expand All @@ -374,14 +363,6 @@ function handle(call, id, payload) {
throw convertSocketError(err);
}
}
case SOCKET_UDP_GET_SEND_BUFFER_SIZE: {
const socket = getUdpSocketOrThrow(id);
try {
return BigInt(socket.getSendBufferSize());
} catch (err) {
throw convertSocketError(err);
}
}
case SOCKET_UDP_SET_SEND_BUFFER_SIZE: {
const socket = getUdpSocketOrThrow(id);
try {
Expand Down
Loading

0 comments on commit e6325fa

Please sign in to comment.