Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

HTTP Con. Error java.net.BindException: Address already in use: connect

843810Oct 13 2005 — edited Oct 13 2005
Hi, i want to test a program that requests to a servlet continuously, then save the response to SQL (SQL Server 2000) database. But there is a problem.
After a while the program starts, it throws an exception and becomes throwing the same exception at each http request. I dont understand why?
I'm releasing the connection but it can not connect anymore...???
I had many change on the code, but it did not work.

The code for testing is :
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
public class StressTest {
	public static void main(String[] args) {
		while(true) {
			PostMethod post = new PostMethod("http://localhost:8080/cepkisit/cepkisit");
			HttpClient client = new HttpClient();
			try {
				client.executeMethod(post);
				//System.out.println("post gerceklesti.");
			} catch (Exception e) {
				e.printStackTrace();
				break;
			} finally {
				post.releaseConnection();				
			}
		}
	}
}
The Exception :
java.net.BindException: Address already in use: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:86)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:652)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:628)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:497)
at alper.StressTest.main(StressTest.java:25)

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 10 2005
Added on Oct 13 2005
2 comments
1,786 views