I have to open plenty of TCP connections to a SIP server which is runnning on linux. I tried with one simple client program in Java, but I could not open even 350 connections from another linux server. I want to open ~ 50 thousand and above for a load/performance test.
Is there any way to overcome this? What are the limitations? Sorry if this is a silly question,I am a Beginner.
Thanks
client program
public class ConnectionTcp
{
static int noOfconnected;
Socket socket;
static int port=1000;
static Object obj=new Object();
static AtomicInteger atomicInteger;
public static void main(String[]args)
{
try{
ConnectionTcp con=new ConnectionTcp();
atomicInteger = new AtomicInteger();
Date date = new Date();
for(int i=0;i<50000;i++)
{
port+=i;
con.sendmsg();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public synchronized void sendmsg(){
try{
Thread.sleep(100);
}
catch(Exception e){
System.out.println(e);
}
Runnable r=new Runnable(){
public void run(){
try{
boolean check=true;
InetAddress ip=InetAddress.getByName("131.10.20.16");
Socket socket=new Socket("131.10.20.17",5060,ip,port);
System.out.println("conected is "+socket.isConnected()+"<----------with port----------->"+socket.getLocalPort());
OutputStream out =socket.getOutputStream();
InputStream in =socket.getInputStream();
String str = "keep alive";
byte[] array = str.getBytes();
System.out.println("no of user connected with server is "+atomicInteger.incrementAndGet());
while(true){
try{
int i = in.read();
out.write(array);
}catch(Exception e){
System.out.println("exception"+e);
atomicInteger.decrementAndGet();
socket.close();
Date date = new Date();
System.out.println("Ented Time is "+date.toString());
break;
}
}
}catch(Exception e1){
System.out.println("main exception"+e1);
atomicInteger.decrementAndGet();
}
}
};
(new Thread(r,"tcp")).start();
}
}