1

I have two applications that need to communicate with each other running on the same system.

I've been using the very strange practice of opening a TCP COM channel between the two applications for communication.

Is this practice frowned-upon in anyway? Is there any alternative (apart from using stdio, not possible due to other reasons).

Is there a restriction on maximum transfer rate and/or any latency involved (compared to piped stdio)?

I'm using the local (127.0.0.1) address for both server and client, will the connection be guaranteed to stay within the local machine itself or could it relay off the nearest router before coming back to itself and does the network card influence the properties of the connection at all?

initramfs
  • 8,275
  • 2
  • 36
  • 58

2 Answers2

1

I worked on a system a while ago with Java. and I was looking for the same question. I don't have much experience with it. But I ended up using tcp connections for communications for the following advantages:

1) The ability to put the different application in different servers in the future if needed to. 2) The applications are totaly independent. one application could crash without effecting the other one. If the working application then tries to connect it gets an error and you can handle that.

I saw this used in many other type of applications. So I went with it and it is working fine. But you have to be carefull and handle networks errors and IO errors and closing all open sockets after finishing with the connection. I was only closing the socket from the client end so I ended up with many CLOSE_WAIT ports in the server.

Regards,

ahmedalkaff
  • 313
  • 1
  • 3
  • Yeah. I get what you mean, I was thinking of the same things as well. At the instant I thought of it I thought it was a ingenious idea... but then considering it now.. I never really considered the possible downsides of it. Well... Thanks for letting me know that other people have done this too but I'm afraid you didn't specifically answer my question. – initramfs Aug 18 '13 at 08:24
0

It's pretty common to use TCP for inter-application communication.

Performance should not be an issue. Sockets On Same Machine For Windows and Linux

You should consider security. What will happen if another user on the machine connects to the port, how will the application authenticate etc.

Community
  • 1
  • 1
  • Well... its not really a application that requires high security... the two applications start simultaneously anyway... so the window of "attack" is very very small. – initramfs Aug 18 '13 at 08:51