xingyu
xingyu

Reputation: 332

Sockets and DatagramChannels

I am trying to write a piece of software that

So it is a simple intermediate server.

To visualise the communication:

Client <---> Intermediate Server <---> "Real" Server

The client connects to the Intermediate but has no idea that the message it sends is being forwarded to another server, or that it's reply is actually from another server. As far as the client cares it the Intermediate server is the real server.

I am trying to use Java's DatagramChannel for this, but not quite sure how to correctly do this in a non-hack way. Do I use two DatagramChannels? One for Client--Intermediate and the other for Intermediate--Real Server?

An general outline of approach would be appreciated, particularly if I need to open a socket every time I need to forward a message from the Intermediate to the Real Server, or if I can keep that socket open somehow.

Upvotes: 0

Views: 247

Answers (1)

user207421
user207421

Reputation: 311055

You only need one datagram socket for this, and you can keep it open for the life of the process.

Upvotes: 1

Related Questions