socket serious problem in jdk 1.5+

C

cmk128

Hi
The following line cannot connect to 192.158.0.2 port 21 if i use jdk
1.5 update 3 or jdk 1.5 update 4:
Socket socket = new Socket("192.168.0.2",21);
If i use jdk1.4.2 to run the above code, it got no problem.

If the your computer ip is 192.168.0.2, you got no problem even you use
jdk1.5

thanks
from Peter ([email protected])
 
C

cmk128

Sorry, it was my mistake, new Socket(IP,port) work both 1.4.2 and 1.5

But with jdk1.5, new Socket(hostname,port) is much faster than new
Socket(hostname,port).
In jdk1.4.2, both are same speed.
Why?
thanks
from Peter ([email protected])
 
R

Roland

Hi
The following line cannot connect to 192.158.0.2 port 21 if i use jdk
1.5 update 3 or jdk 1.5 update 4:
Socket socket = new Socket("192.168.0.2",21);
If i use jdk1.4.2 to run the above code, it got no problem.

If the your computer ip is 192.168.0.2, you got no problem even you use
jdk1.5

thanks
from Peter ([email protected])
Do you have a firewall? Make sure that the java 1.5 executable is
allowed to connect to that port on that specific host. (Maybe in the
past you've configured your firewall to allow the java 1.4.2 executable
to access the internet)
--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
R

Roland

Hi
The following line cannot connect to 192.158.0.2 port 21 if i use jdk
1.5 update 3 or jdk 1.5 update 4:
Socket socket = new Socket("192.168.0.2",21);
If i use jdk1.4.2 to run the above code, it got no problem.

If the your computer ip is 192.168.0.2, you got no problem even you use
jdk1.5

thanks
from Peter ([email protected])
Do you have a firewall? Make sure that the java 1.5 executable is
allowed to connect to that port on that specific host. (Maybe in the
past you've configured your firewall to allow the java 1.4.2 executable
to access the internet)
--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
C

cmk128

i am sure i turn all the firewall/ microsoft antispam-ware off
thanks for your reply
 
C

cmk128

i am sure i turn all the firewall/ microsoft antispam-ware off
thanks for your reply
 
R

Roedy Green

Sorry, it was my mistake, new Socket(IP,port) work both 1.4.2 and 1.5

But with jdk1.5, new Socket(hostname,port) is much faster than new
Socket(hostname,port).
In jdk1.4.2, both are same speed.
Why?
thanks

I think you need to restate that. I can't see any difference between
the two things so how could one be faster?

I think you meant an IP in there somewhere.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
C

cmk128

I don't know why new Socket(hostname,port) is faster than new
Socket(IP,port) in jdk 1.5?

And i found my windows is crazy, when i "telnet 127.0.0.1 21", it can
connect, but after 1 second , it becomes disconnect. Really don't know
which service is using port 21.
If there is a service using port 21, i don't think i can bind port 21
in Java Socket, but i really can do it.


thanks
from Peter
 
T

Thomas Hawtin

And i found my windows is crazy, when i "telnet 127.0.0.1 21", it can
connect, but after 1 second , it becomes disconnect. Really don't know
which service is using port 21.
If there is a service using port 21, i don't think i can bind port 21
in Java Socket, but i really can do it.

To see which ports are listening type "netstat -a" in Windows or
"netstat -a -A inet" in Linux/UNIX. Add -n to get numeric addresses
(which might be much faster if your DNS is broken).

Tom Hawtin
 
P

pwt

I don't know why new Socket(hostname,port) is faster than new
Socket(IP,port) in jdk 1.5?

The source for those methods comes with both development kit's, look
and see for yourself.
And i found my windows is crazy, when i "telnet 127.0.0.1 21", it can
connect, but after 1 second , it becomes disconnect. Really don't know
which service is using port 21.

Port 21 is typically used by FTP servers. If you aren't running one on
our computer, the connection will be refused. There is nothing crazy
about this, you cannot open a connection to a port when there is no
program listening on that port.
If there is a service using port 21, i don't think i can bind port 21
in Java Socket, but i really can do it.

While it is true that you cannot listen on a port that's already be
listened on by another program, as far as you've shown here, this is
not the case. You are trying to create an outbound connection which has
nothing to do with port binding.
thanks
from Peter

I think you might want to search Google for a primer on TCP/IP and
socket programming, you might find it helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top