|
48 | 48 | import java.io.IOException;
|
49 | 49 | import java.net.InetAddress;
|
50 | 50 | import java.net.InetSocketAddress;
|
51 |
| -import java.net.SocketAddress; |
52 | 51 | import java.nio.ByteBuffer;
|
53 | 52 | import java.nio.channels.NotYetConnectedException;
|
54 | 53 | import java.nio.channels.ServerSocketChannel;
|
@@ -129,16 +128,18 @@ Object accept(PSocket socket) {
|
129 | 128 | if (acceptSocket == null) {
|
130 | 129 | throw raiseOSError(null, OSErrorEnum.EWOULDBLOCK);
|
131 | 130 | }
|
132 |
| - SocketAddress addr = acceptSocket.getLocalAddress(); |
133 |
| - if (!acceptSocket.socket().isBound() || addr == null) { |
| 131 | + InetSocketAddress remoteAddress = (InetSocketAddress) acceptSocket.getRemoteAddress(); |
| 132 | + if (!acceptSocket.socket().isBound() || remoteAddress == null) { |
134 | 133 | throw raise(OSError);
|
135 | 134 | }
|
136 | 135 | PSocket newSocket = factory().createSocket(socket.getFamily(), socket.getType(), socket.getProto());
|
137 | 136 | int fd = getContext().getResources().openSocket(newSocket);
|
138 | 137 | newSocket.setFileno(fd);
|
139 | 138 | newSocket.setSocket(acceptSocket);
|
140 |
| - Object[] output = {fd, ((InetSocketAddress) addr).getAddress().getHostAddress()}; |
141 |
| - return factory().createTuple(output); |
| 139 | + SocketUtils.setBlocking(newSocket, socket.isBlocking()); |
| 140 | + newSocket.setTimeout(socket.getTimeout()); |
| 141 | + PTuple addressTuple = factory().createTuple(new Object[]{remoteAddress.getAddress().getHostAddress(), remoteAddress.getPort()}); |
| 142 | + return factory().createTuple(new Object[]{fd, addressTuple}); |
142 | 143 | } catch (IOException e) {
|
143 | 144 | throw raise(OSError);
|
144 | 145 | }
|
|
0 commit comments