• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connection refused: connect

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i have this problem: i got this C server which is waiting for the java clients to arrive. first i connect a client (socket = new Socket ("localhost", 25557) and then i quit de client, then i do this again and no problem, but the third time i get this exception:

java.net.ConnectException: Connection refused: 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 queryAnalyzer.action(queryAnalyzer.java:314)
at Socket_server$Client.run(Socket_server.java:38)
at ThreadPoolWorker.runIt(ThreadPoolWorker.java:72)
at ThreadPoolWorker.runWork(ThreadPoolWorker.java:63)
at ThreadPoolWorker.access$000(ThreadPoolWorker.java:3)
at ThreadPoolWorker$1.run(ThreadPoolWorker.java:25)
at java.lang.Thread.run(Thread.java:534)

I know i�m not providing too much info about my program, but it would be difficult to do it in a few lines, so if you could point me in any direction so i could start looking for the failure, or give me any clue about what to look for, i would be very grateful!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either the C server is written to accept only one client and then quit, or it can only take one client at a time and your client isn't disconnecting properly (i.e., maybe you need to send a particular command before closing the socket.) Do you have the source for the server?
 
Gus Spain
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, i have all the source code, and the c server is an endless loop waiting for the clients, when there�s an accept the server checks the maximun number of threads (20) hadn�t been reached, if it hadn�t been reached it creates the thread to serve the client, if not it returns an error code. In order to end the execution, the java client sends a message to its C thread, so it can do the closesocket(msgsock).
The point is why does it work perfectly the first two times and then it fails? Because this kind of error seems to be more on the C server side than in the java side, right?
Thanks!
[ November 17, 2004: Message edited by: Gus Spain ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic