Socket exception caused by a recv failed

Charlie Consumer <[email protected]> Wed, 1 Mar 2006 10:51:32 -0800
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
Hi,

I currently have a problem where I'm getting the
following exception:

java.net.SocketException: No buffer space available
(maximum connections reached?): recv failed

It only happens on a Windows 2000 box.  I've tested
this on XP and Windows 2003 and I can't get it to
fail.  I've checked my machine, but I don't see any
problem with RMI using too many sockets.  When I do a
netstat -a -n I don't have that many sockets running.
But, I just can't seem to figure out why this is
failing.  I've attached a sample application I'm using
to reproduce this out side of my app.  What I have
figured out is I can do an RMI lookup, and I can do
some remote calls, but eventually it blows up with
this exception after only a few calls.

I'm at a loss for what's going on.

netstat -a -n while running the clients

Active Connections

  Proto  Local Address          Foreign Address
State
  TCP    0.0.0.0:7              0.0.0.0:0
LISTENING
  TCP    0.0.0.0:9              0.0.0.0:0
LISTENING
  TCP    0.0.0.0:13             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:17             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:19             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:21             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:23             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:42             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:53             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:80             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:98             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:99             0.0.0.0:0
LISTENING
  TCP    0.0.0.0:135            0.0.0.0:0
LISTENING
  TCP    0.0.0.0:443            0.0.0.0:0
LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0
LISTENING
  TCP    0.0.0.0:515            0.0.0.0:0
LISTENING
  TCP    0.0.0.0:548            0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1025           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1028           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1032           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1034           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1037           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1038           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1052           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1054           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1061           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:1063           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3280           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3453           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3912           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3913           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3914           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3915           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3916           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3917           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3918           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3919           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3920           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3922           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3923           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3924           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3925           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3926           0.0.0.0:0
LISTENING
  TCP    0.0.0.0:3927           0.0.0.0:0
LISTENING
  TCP    172.16.3.101:98        172.16.3.101:3912
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3913
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3914
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3915
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3916
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3917
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3918
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3919
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3920
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3922
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3923
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3924
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3925
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3926
ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3927
ESTABLISHED
  TCP    172.16.3.101:139       0.0.0.0:0
LISTENING
  TCP    172.16.3.101:1061      72.5.124.55:80
CLOSE_WAIT
  TCP    172.16.3.101:1063      193.45.10.119:80
CLOSE_WAIT
  TCP    172.16.3.101:3453      209.134.174.46:445
ESTABLISHED
  TCP    172.16.3.101:3885      172.16.3.101:99
TIME_WAIT
  TCP    172.16.3.101:3912      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3913      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3914      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3915      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3916      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3917      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3918      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3919      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3920      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3922      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3923      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3924      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3925      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3926      172.16.3.101:98
ESTABLISHED
  TCP    172.16.3.101:3927      172.16.3.101:98
ESTABLISHED
  UDP    0.0.0.0:7              *:*
  UDP    0.0.0.0:9              *:*
  UDP    0.0.0.0:13             *:*
  UDP    0.0.0.0:17             *:*
  UDP    0.0.0.0:19             *:*
  UDP    0.0.0.0:42             *:*
  UDP    0.0.0.0:68             *:*
  UDP    0.0.0.0:161            *:*
  UDP    0.0.0.0:445            *:*
  UDP    0.0.0.0:1027           *:*
  UDP    0.0.0.0:1645           *:*
  UDP    0.0.0.0:1646           *:*
  UDP    0.0.0.0:1812           *:*
  UDP    0.0.0.0:1813           *:*
  UDP    0.0.0.0:3456           *:*
  UDP    127.0.0.1:53           *:*
  UDP    127.0.0.1:1026         *:*
  UDP    127.0.0.1:1031         *:*
  UDP    127.0.0.1:1035         *:*
  UDP    127.0.0.1:1036         *:*
  UDP    172.16.3.101:53        *:*
  UDP    172.16.3.101:67        *:*
  UDP    172.16.3.101:68        *:*
  UDP    172.16.3.101:137       *:*
  UDP    172.16.3.101:138       *:*
  UDP    172.16.3.101:500       *:*
  UDP    172.16.3.101:2535      *:*


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html
rmi-error-data.txt (text/plain, 17.2 KB)
Exception in thread "main" java.rmi.ConnectIOException: error during JRMP connec
tion establishment; nested exception is:
        java.net.SocketException: No buffer space available (maximum connections reached?): recv failed
        at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
        at Client.main(Client.java:36)
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): recv failed
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at java.io.DataInputStream.readByte(Unknown Source)
        ... 3 more

netstat -a -n while running the clients

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:7              0.0.0.0:0              LISTENING
  TCP    0.0.0.0:9              0.0.0.0:0              LISTENING
  TCP    0.0.0.0:13             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:17             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:19             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:21             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:23             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:42             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:53             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:98             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:99             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:443            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:515            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:548            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1025           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1028           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1032           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1034           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1037           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1038           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1052           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1054           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1061           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1063           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3280           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3453           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3912           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3913           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3914           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3915           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3916           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3917           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3918           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3919           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3920           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3922           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3923           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3924           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3925           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3926           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3927           0.0.0.0:0              LISTENING
  TCP    172.16.3.101:98        172.16.3.101:3912      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3913      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3914      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3915      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3916      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3917      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3918      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3919      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3920      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3922      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3923      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3924      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3925      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3926      ESTABLISHED
  TCP    172.16.3.101:98        172.16.3.101:3927      ESTABLISHED
  TCP    172.16.3.101:139       0.0.0.0:0              LISTENING
  TCP    172.16.3.101:1061      72.5.124.55:80         CLOSE_WAIT
  TCP    172.16.3.101:1063      193.45.10.119:80       CLOSE_WAIT
  TCP    172.16.3.101:3453      209.134.174.46:445     ESTABLISHED
  TCP    172.16.3.101:3885      172.16.3.101:99        TIME_WAIT
  TCP    172.16.3.101:3912      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3913      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3914      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3915      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3916      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3917      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3918      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3919      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3920      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3922      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3923      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3924      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3925      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3926      172.16.3.101:98        ESTABLISHED
  TCP    172.16.3.101:3927      172.16.3.101:98        ESTABLISHED
  UDP    0.0.0.0:7              *:*
  UDP    0.0.0.0:9              *:*
  UDP    0.0.0.0:13             *:*
  UDP    0.0.0.0:17             *:*
  UDP    0.0.0.0:19             *:*
  UDP    0.0.0.0:42             *:*
  UDP    0.0.0.0:68             *:*
  UDP    0.0.0.0:161            *:*
  UDP    0.0.0.0:445            *:*
  UDP    0.0.0.0:1027           *:*
  UDP    0.0.0.0:1645           *:*
  UDP    0.0.0.0:1646           *:*
  UDP    0.0.0.0:1812           *:*
  UDP    0.0.0.0:1813           *:*
  UDP    0.0.0.0:3456           *:*
  UDP    127.0.0.1:53           *:*
  UDP    127.0.0.1:1026         *:*
  UDP    127.0.0.1:1031         *:*
  UDP    127.0.0.1:1035         *:*
  UDP    127.0.0.1:1036         *:*
  UDP    172.16.3.101:53        *:*
  UDP    172.16.3.101:67        *:*
  UDP    172.16.3.101:68        *:*
  UDP    172.16.3.101:137       *:*
  UDP    172.16.3.101:138       *:*
  UDP    172.16.3.101:500       *:*
  UDP    172.16.3.101:2535      *:*

J:\>netstat -a -n

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:7              0.0.0.0:0              LISTENING
  TCP    0.0.0.0:9              0.0.0.0:0              LISTENING
  TCP    0.0.0.0:13             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:17             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:19             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:21             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:23             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:42             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:53             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:98             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:99             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:443            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:515            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:548            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1025           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1028           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1032           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1034           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1037           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1038           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1052           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1054           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1061           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1063           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3280           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3453           0.0.0.0:0              LISTENING
  TCP    172.16.3.101:139       0.0.0.0:0              LISTENING
  TCP    172.16.3.101:1061      72.5.124.55:80         CLOSE_WAIT
  TCP    172.16.3.101:1063      193.45.10.119:80       CLOSE_WAIT
  TCP    172.16.3.101:3453      209.134.174.46:445     ESTABLISHED
  TCP    172.16.3.101:3885      172.16.3.101:99        TIME_WAIT
  UDP    0.0.0.0:7              *:*
  UDP    0.0.0.0:9              *:*
  UDP    0.0.0.0:13             *:*
  UDP    0.0.0.0:17             *:*
  UDP    0.0.0.0:19             *:*
  UDP    0.0.0.0:42             *:*
  UDP    0.0.0.0:68             *:*
  UDP    0.0.0.0:161            *:*
  UDP    0.0.0.0:445            *:*
  UDP    0.0.0.0:1027           *:*
  UDP    0.0.0.0:1645           *:*
  UDP    0.0.0.0:1646           *:*
  UDP    0.0.0.0:1812           *:*
  UDP    0.0.0.0:1813           *:*
  UDP    0.0.0.0:3456           *:*
  UDP    127.0.0.1:53           *:*
  UDP    127.0.0.1:1026         *:*
  UDP    127.0.0.1:1031         *:*
  UDP    127.0.0.1:1035         *:*
  UDP    127.0.0.1:1036         *:*
  UDP    172.16.3.101:53        *:*
  UDP    172.16.3.101:67        *:*
  UDP    172.16.3.101:68        *:*
  UDP    172.16.3.101:137       *:*
  UDP    172.16.3.101:138       *:*
  UDP    172.16.3.101:500       *:*
  UDP    172.16.3.101:2535      *:*

J:\>netstat -a -n

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:7              0.0.0.0:0              LISTENING
  TCP    0.0.0.0:9              0.0.0.0:0              LISTENING
  TCP    0.0.0.0:13             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:17             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:19             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:21             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:23             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:42             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:53             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:98             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:99             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:443            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:515            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:548            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1025           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1028           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1032           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1034           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1037           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1038           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1052           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1054           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1061           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1063           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3280           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3453           0.0.0.0:0              LISTENING
  TCP    172.16.3.101:139       0.0.0.0:0              LISTENING
  TCP    172.16.3.101:1061      72.5.124.55:80         CLOSE_WAIT
  TCP    172.16.3.101:1063      193.45.10.119:80       CLOSE_WAIT
  TCP    172.16.3.101:3453      209.134.174.46:445     ESTABLISHED
  TCP    172.16.3.101:3885      172.16.3.101:99        TIME_WAIT
  UDP    0.0.0.0:7              *:*
  UDP    0.0.0.0:9              *:*
  UDP    0.0.0.0:13             *:*
  UDP    0.0.0.0:17             *:*
  UDP    0.0.0.0:19             *:*
  UDP    0.0.0.0:42             *:*
  UDP    0.0.0.0:68             *:*
  UDP    0.0.0.0:161            *:*
  UDP    0.0.0.0:445            *:*
  UDP    0.0.0.0:1027           *:*
  UDP    0.0.0.0:1645           *:*
  UDP    0.0.0.0:1646           *:*
  UDP    0.0.0.0:1812           *:*
  UDP    0.0.0.0:1813           *:*
  UDP    0.0.0.0:3456           *:*
  UDP    127.0.0.1:53           *:*
  UDP    127.0.0.1:1026         *:*
  UDP    127.0.0.1:1031         *:*
  UDP    127.0.0.1:1035         *:*
  UDP    127.0.0.1:1036         *:*
  UDP    172.16.3.101:53        *:*
  UDP    172.16.3.101:67        *:*
  UDP    172.16.3.101:68        *:*
  UDP    172.16.3.101:137       *:*
  UDP    172.16.3.101:138       *:*
  UDP    172.16.3.101:500       *:*
  UDP    172.16.3.101:2535      *:*

J:\>

batch file client.bat
---------------------
java  Client 98 20


batch file clients.bat
----------------------
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat
start client.bat


Client.java
-----------

import java.net.Socket;
import java.rmi.Naming;
import java.util.LinkedList;
import java.util.List;

import sun.rmi.transport.Channel;
import sun.rmi.transport.Connection;
import sun.rmi.transport.Endpoint;
import sun.rmi.transport.tcp.TCPEndpoint;

public class Client {

        /**
         * @param args
         */
        public static void main(String[] args) throws Exception{
                int registryPort = new Integer(args[0]);
                int count = new Integer(args[1]);


//              List<Socket> sockets = new LinkedList<Socket>();
                for (int i = 0; i < count; i++) {
//                      Socket sock = new Socket(InetAddress.getLocalHost(), registryPort);
//
//                      DataOutputStream ostm = new DataOutputStream(sock.getOutputStream());
//                      ostm.writeInt(TransportConstants.Magic);
//                      ostm.writeShort(TransportConstants.Version);
//                      ostm.writeByte(TransportConstants.StreamProtocol);
//                      ostm.flush();
//
//                      sock.getInputStream().read();
//                      sockets.add(sock);

                         Endpoint ep = TCPEndpoint.getLocalEndpoint(registryPort);
                         Channel channel = ep.getChannel();
                         Connection conn = channel.newConnection();
                         channel.free(conn, true);



                        System.out.println("Connected OK");
                }
                Thread.sleep(8000);
//              for (Socket sock : sockets) {
//                      sock.close();
//              }
        }
}

Server.java
-----------
import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;

public class RMIServer {

        /**
         * @param args
         * @throws Exception
         */
        public static void main(String[] args) throws Exception {
                int registryPort = new Integer(args[0]);
                int rmiPort = new Integer(args[1]);
                String serviceName = args[2];

                LocateRegistry.createRegistry(registryPort);
                Naming.rebind(serviceName, new AService(rmiPort));

        }

}

service.bat
-----------
java RMIServer 98 99 //localhost:98/service

Service.java
------------
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Service extends Remote{
        void doIt() throws RemoteException;

}

AService.java
-------------
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class AService extends UnicastRemoteObject implements Service {

        /**
         *
         */
        private static final long serialVersionUID = 5926195464326528718L;

        protected AService(int port) throws RemoteException {
                super(port);
        }

        public void doIt() {
                System.out.println("doing it");
        }

}



===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html