--- a/src/JavaVM.st Sun Nov 13 22:56:44 2011 +0000
+++ b/src/JavaVM.st Sun Nov 13 22:57:59 2011 +0000
@@ -7389,6 +7389,7 @@
self throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed'.
].
jsock instVarNamed: #localport put: sock port.
+ jsock instVarNamed: #address put: jaddr.
] on: Error do:[:ex|
self throwExceptionClassName:'java.net.ConnectException' withMessage:'connect failed: ', ex description
].
@@ -7397,7 +7398,7 @@
"Created: / 25-01-1998 / 20:02:27 / cg"
"Modified: / 30-12-1998 / 20:10:28 / cg"
- "Modified: / 09-11-2011 / 22:59:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-11-2011 / 23:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_PlainSocketImpl_socketCreate: nativeContext
@@ -7425,9 +7426,9 @@
].
isStream ifTrue:[
- sock := Socket newTCP
+ sock := JavaSocket newTCP
] ifFalse:[
- sock := Socket newUDP
+ sock := JavaSocket newUDP
].
sock isNil ifTrue:[
self throwIOExceptionWithMessage:'socketCreate failed'.
@@ -7450,14 +7451,75 @@
"Created: / 25-01-1998 / 19:59:25 / cg"
"Modified: / 30-12-1998 / 20:10:38 / cg"
- "Modified: / 07-11-2011 / 23:20:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-11-2011 / 20:46:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_PlainSocketImpl_socketGetOption: nativeContext
<javanative: 'java/net/PlainSocketImpl' name: 'socketGetOption(ILjava/lang/Object;)I'>
- ^ UnimplementedNativeMethodSignal raise
+ | opt arg sock ret |
+ opt := nativeContext argAt: 1.
+ arg := nativeContext argAt: 2.
+
+ sock := self validateFile: nativeContext receiver.
+
+"/ TCP_NODELAY = 1;
+ opt = 1 ifTrue:[
+ ret := sock getSocketOption: #TCP_NODELAY.
+ ^ret ifTrue:[1] ifFalse:[-1].
+ ].
+"/ SO_BINDADDR = 15;
+ opt = 15 ifTrue:[
+ self breakPoint: #jv.
+ ^-1 "/Unsupported
+ ].
+
+"/ SO_REUSEADDR = 4;
+ opt = 4 ifTrue:[
+ ret := sock getSocketOption: #SO_REUSEADDR.
+ ^ret ifTrue:[1] ifFalse:[-1].
+ ].
+"/ IP_TOS = 3;
+ opt = 3 ifTrue:[
+ self breakPoint: #jv.
+ ^-1 "/Unsupported
+ ].
+"/ SO_LINGER = 128;
+ opt = 128 ifTrue:[
+ ret := sock getSocketOption:#SO_LINGER.
+ ^ret
+ ].
+"/ SO_TIMEOUT = 4102;
+ opt = 4102 ifTrue:[
+ self breakPoint: #jv.
+ ^-1 "/Unsupported .
+ ].
+"/ SO_SNDBUF = 4097;
+ opt = 4097 ifTrue:[
+ ret := sock getSocketOption: #SO_SNDBUF.
+ ^ret
+ ].
+
+"/ SO_RCVBUF = 4098;
+ opt = 4098 ifTrue:[
+ ret := sock getSocketOption: #SO_RCVBUF.
+ ^ret
+ ].
+
+"/ SO_KEEPALIVE = 8;
+ opt = 8 ifTrue:[
+ ret := sock getSocketOption: #SO_KEEPALIVE.
+ ^ret ifTrue:[1] ifFalse:[-1].
+ ].
+
+"/ SO_OOBINLINE = 4099;
+ opt = 4099 ifTrue:[
+ ret := sock getSocketOption: #SO_OOBINLINE.
+ ^ret ifTrue:[1] ifFalse:[-1].
+ ]
+
+ "Modified: / 13-11-2011 / 23:06:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_PlainSocketImpl_socketListen: nativeContext
@@ -7492,10 +7554,10 @@
<javanative: 'java/net/PlainSocketImpl' name: 'socketSetOption(IZLjava/lang/Object;)V'>
- | opt on val sock o arg1 |
+ | opt on val sock o arg1 arg2 |
opt := nativeContext argAt: 1.
on := nativeContext argAt: 2.
- val := nativeContext argAt: 2.
+ val := nativeContext argAt: 3.
sock := self validateFile: nativeContext receiver.
@@ -7520,8 +7582,9 @@
].
"/ SO_LINGER = 128;
opt = 128 ifTrue:[
- o := #SO_DONTLINGER.
- arg1 := (on == 0)
+ o := #SO_LINGER.
+ arg1 := (on == 1).
+ arg2 := val instVarNamed: #value.
].
"/ SO_TIMEOUT = 4102;
opt = 4102 ifTrue:[
@@ -7553,12 +7616,12 @@
].
[
- sock setSocketOption: o argument: arg1 argument: nil.
+ sock setSocketOption: o argument: arg1 argument: arg2.
] on: Error do:[:ex|
self throwSocketException: 'Error setting socket option: ', ex description.
].
- "Modified: / 09-11-2011 / 23:32:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-11-2011 / 23:05:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_SocketInputStream_init: nativeContext
@@ -7600,14 +7663,14 @@
].
[
- nread := sock next: len into: data startingAt: off.
+ nread := sock readInto: data startingAt: off count: len.
] on: Error do:[:ex|
self throwSocketException: 'Error when reading: ', ex description.
].
^nread
- "Modified: / 09-11-2011 / 22:51:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 13-11-2011 / 23:49:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_SocketOutputStream_init: nativeContext
@@ -7623,7 +7686,27 @@
<javanative: 'java/net/SocketOutputStream' name: 'socketWrite0(Ljava/io/FileDescriptor;[BII)V'>
- ^ UnimplementedNativeMethodSignal raise
+ | fdObj data off len sock |
+ fdObj := nativeContext argAt:1.
+ data := nativeContext argAt:2.
+ off := nativeContext argAt:3.
+ len := nativeContext argAt:4.
+
+
+ fdObj isNil ifTrue:[
+ self throwSocketException: 'Socket closed (null fdObj passed to socketRead0)'.
+ ^ -1.
+ ].
+
+ sock := self validateFile: fdObj.
+
+ [
+ sock nextPutBytes: len from: data startingAt: off.
+ ] on: Error do:[:ex|
+ self throwIOExceptionWithMessage: 'Error when writing: ', ex description.
+ ].
+
+ "Modified: / 13-11-2011 / 23:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaVM class methodsFor:'native - java.security'!
@@ -17516,4 +17599,3 @@
! !
JavaVM initialize!
-