Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the need of socket if both the server and client process on same machine?

Tags:

sockets

I am relatively new to programming and am attempting to self learn socket programming. As per my understanding, a socket is needed at both endpoints if a process (say server process) needs to communicate with another process (say client process) over the network.

If my server and client processes are on the same machine, then why do I need sockets because the streams or datagrams are not going over the network? It's within the same machine. Can anybody please clarify the reason for this?

like image 898
Subi Puthalath Avatar asked May 09 '13 11:05

Subi Puthalath


1 Answers

Then how do two processes on the same machine communicate without using sockets?

...

That's right, sockets are a way for two processes to communicate regardless of whether it's over the network or within the same machine. You could invent other mechanisms for communication within the same machine (and there are plenty), but why if sockets already serve that purpose perfectly fine?

like image 163
deceze Avatar answered Oct 06 '22 00:10

deceze