b******e 发帖数: 671 | 1 I try to create a server socket on port 80 using
ServerSocket s = new ServerSocket(80);
But it always open the TCP port 80 on IP 0.0.0.0.
What I want is to open the port 80 on my local IP, such as
192.168.0.100.
By the way, I use comcast for internet. The IPCONFIG of my machine looks
like
Ethernet adapter local area connection:
Connection DNS Suffix : hsd1..comcast..
IP address : 192.168.0.100
Subnet Mask : 255...
Default Gateway : 192...
Ethernet adapter {1BXXXX-4 | s******n 发帖数: 876 | 2 give the constructor the explicit IP address.
this may work:
new ServerSocket(80,50, InetAddress.getLocalHost()); | b******e 发帖数: 671 | 3 Thanks a lot. It helps.
Now, I can see from NETSTAT that the port 80 of IP 192.168.0.100 is
Listening.
When I try to open a client socket to connect with server, such as
Socket sock = new Socket("192.168.0.100", 80);
It throws a "connection refuse" exception. Any suggestion?
By the way, I turned off the XP firewall. | q*********u 发帖数: 280 | 4 你这个是80端口,估计有apache或者iis的service开在那里,关掉
当然没有强行要求,最好不要用80
【在 b******e 的大作中提到】 : Thanks a lot. It helps. : Now, I can see from NETSTAT that the port 80 of IP 192.168.0.100 is : Listening. : When I try to open a client socket to connect with server, such as : Socket sock = new Socket("192.168.0.100", 80); : It throws a "connection refuse" exception. Any suggestion? : By the way, I turned off the XP firewall.
| b******e 发帖数: 671 | 5 没装APACHE/IIS.
其它的端口也试过(8080,12345,...), 也不行.
不知道是不是JAVA SDK, JAVA JRE版本不同之类的问题. | m******t 发帖数: 2416 | 6 First run "netstat -ltnp" to make sure it is your process that's listening
on the port.
Then run "telnet 192.168.0.100 80" from command line to try the connection.
【在 b******e 的大作中提到】 : Thanks a lot. It helps. : Now, I can see from NETSTAT that the port 80 of IP 192.168.0.100 is : Listening. : When I try to open a client socket to connect with server, such as : Socket sock = new Socket("192.168.0.100", 80); : It throws a "connection refuse" exception. Any suggestion? : By the way, I turned off the XP firewall.
|
|