user547453
user547453

Reputation: 1045

Using Sockets along with RMI

I have implemented a RMI solution, where my client program can get a datasource object from a DB pool in a Server program . Both run on local host (I am still a newbiew ;) )

But then I was looking at one of the posts in SO and it mentioned about wrapping a socket first and then use the RMI to access the remote access object.

Java RMI not closing socket after lease expiration

I also read that RMI also uses Sockets internally.

My question is if I have to create a wrapper on the Socket instance and then use RMI, should I create Sockets (server and client sockets) by myself and then use RMI....if yes...then how to do it? I have learnt to create sockets and RMI but not use them together.

Upvotes: 0

Views: 684

Answers (1)

Chris Cooper
Chris Cooper

Reputation: 5122

Unless you plan to write and control the protocol for communication between client and server, stick to using an RMI client to interrogate a server and use the RMI server to respond.

Also, a DataSource instance is not something you should serialise and distribute to clients. Typically I would expect that when the client makes requests for data, that the server would use the data source to access data on behalf of the client, then marshall the results and send them back to the client.

Upvotes: 2

Related Questions