• Post Reply Bookmark Topic Watch Topic
  • New Topic

checking for an open connection

 
johan van der zen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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!
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Neerav Narielwala
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html
too can help you..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!