wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Socket connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Socket connection" Watch "Socket connection" New topic
Author

Socket connection

Joshua Fix
Ranch Hand

Joined: Sep 18, 2007
Posts: 57
I'm using sockets for my network connection. I open a new socket for each transaction and then shut it down. Is this acceptable? Is this what other people are doing, or should I persist the session until the client is shut down?


SCJP 5.0
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
My approach is like this :

when the application starts, it ask the user to input the server address.
Then it connects to the server.
An then the user can book a record and search for record(s) without disconnecting and connecting again.

I used socket connection too, I thought I'm the only one who likes to burdening myself by using socket .

I hope this will help.

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2 : almost done)
Jens Voss
Greenhorn

Joined: Jun 20, 2001
Posts: 14
Originally posted by Jeffry Kristianto Yanuar:
I used socket connection too, I thought I'm the only one who likes to burdening myself by using socket .



Hi Jeffry,

no, I'm with you too - I am using sockets as well, and I don't think it's that much of a burden
It may be just a matter of personal taste, but I like sockets much more because I think it is easier to contol (and customize) communication behavior.

Good luck with whatever is left with your assignment!

Regards,
Jens


Jens Voß
SCJP 5.0 (97%), SCJD (98%), SCWCD (92%)
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Thanks Jens
Joshua Fix
Ranch Hand

Joined: Sep 18, 2007
Posts: 57
Jens, do you keep your socket connection open for the entire client session, or do you open and close a session with each transaction? Does anybody else have any comments on doing one way vs. the other?
Soroj Margun
Ranch Hand

Joined: Jun 15, 2008
Posts: 44
Hi all,

Close socket and reopen it every time that same client connect may cause your machine to run out of port when many client simultaneously connect due to a waiting period gap when closing socket.


SCJP 1.2; SCWCD 1.2,1.4; SCBCD 1.3; SCJD 5.0
 
GeeCON Prague 2014
 
subject: Socket connection