• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

checking for an open connection

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ranchers

i'm developing a client-server "chat" app, what i need is a way in the server program, to check if a connection to a certain host is already opened, if so send a new messagge and keep the connection, else create a new connection and keep it, i'm doing this with sockets, here's the code for the server i have so far,right now the client stops listening after i send data for the first time from the server, although it seems to stay connected, but no messages are getting through unless i reset the connection, i need the client to always be listening for new connections.




hope anyone can help me, i'm not sure if i can do this with sockets so if it isn't possible i hope someone can point me in the right direction(rmi perhaps?).

btw, the server program is going to run on as/400 while the client will run on a normal pc.

thank you!
 
Bartender
Posts: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by johan van der zen:
i need is a way in the server program, to check if a connection to a certain host is already opened, if so send a new messagge and keep the connection, else create a new connection and keep it



That's an odd way to go about things. Usually a server listens to a port and clients connect to it. The server keeps the connection around until the client/server exchange is done (with a chat app this can be a long time). Have a read through the Java Tutorial: All About Sockets. Sockets are ment to be used in a particular fashion. Understanding that will get you a long way toward your goal.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html
too can help you..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic