LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-06-2005, 02:54 AM   #1
joannelai
LQ Newbie
 
Registered: Dec 2005
Posts: 3

Rep: Reputation: 0
Connection Refused


Hi,

I have implemented a simple java application (J2SE 1.4.2) in which contains a server and a client.

The server side has a ServerSocket to listen to the client messages and the client side has a for loop to create many socket to a specific port.

When I run the client, the following stack trace was printed after 4 or 5 sockets are created successfully.

java.net.ConnectException: Connection refused
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:426)
at java.net.Socket.connect(Socket.java:376)
at java.net.Socket.<init>(Socket.java:291)
at java.net.Socket.<init>(Socket.java:119)
at Client.main(Client.java:12)

I have tested this on both RedHat linux 7.2 and RHEL 3.0 AS and both fail. However I run on Windows XP, it runs without any error.

I have increased the ServerSocket backlog parameter on the server side to a bigger number (default is 50) but it makes no difference. Besides, I have modified /usr/include/linux/socket.h in which the constant SOMAXCONN is changed from 128 to 1024 and it doesn't help as well.

I even tested a similar program of Client Socket in C++ to connect to port 3306, but the exception "Could not bind to port." was caught after 5 or 6 sockets are created. So I am quite sure it's sth wrong with the OS (RedHat Linux).

It seems to be there's some controls or limitations in RedHat Linux which causes the program to throw exception when the clients connect faster than the server can accept.

Any help is appreciated.
 
Old 12-06-2005, 05:50 AM   #2
maginotjr
Member
 
Registered: Aug 2004
Location: BR - Floripa
Distribution: Ubuntu 9.10 - 2.6.x.x
Posts: 661

Rep: Reputation: 35
i dont think this have anything to do with network, maybe some missing lib in linux that you have in windows.
 
Old 12-07-2005, 12:54 AM   #3
joannelai
LQ Newbie
 
Registered: Dec 2005
Posts: 3

Original Poster
Rep: Reputation: 0
No, it must be limitation with the Linux 'coz the same program works fine in Windows. I posted a query in Java forum and somebody told me it maybe limited by backlog which is OS dependent, but I have no idea which configuration should be modified to increase the backlog under Linux. (I tried using the method in Java to modify the backlog but no help)

Does somebody has idea to this problem?
 
Old 12-07-2005, 04:40 AM   #4
maginotjr
Member
 
Registered: Aug 2004
Location: BR - Floripa
Distribution: Ubuntu 9.10 - 2.6.x.x
Posts: 661

Rep: Reputation: 35
yeah, I believe it have something to do with some missing librarie and stuff, thats the point, what librarie, what stuff, but strange is not your question, is where you ask it. Maybe in the Programming Subforum you would get better result...


regards
[ ]'s
 
Old 12-11-2005, 09:42 PM   #5
joannelai
LQ Newbie
 
Registered: Dec 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Somehow this problem is not program dependant. I even run a simple C++ socket program in Linux but similar result is returned. What I wonder is if there's some configurations in Linux can be modfiied to increase the backlog to a reasonable value.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket Connection Failed: 111 Connection Refused degraffenried13 Linux - General 3 05-31-2009 01:17 AM
ircd.conf: "Connection failed. Error: Connection refused" hamish Linux - Software 3 03-10-2005 07:23 AM
connection refused Doos Linux - Networking 9 10-18-2004 07:58 AM
lp filename yields "cannot open connection to localhost - Connection refused" jjge Linux - General 3 12-28-2003 11:02 PM
How to get 'connection refused' facefullofsnow Linux - Security 3 12-02-2003 04:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration