Logo Questions Linux Laravel Mysql Ubuntu Git Menu

difference between rpc and normal tcp/udp server client program?

so i have been searching different ways to create client and server program (using visual studios in c++) and i came across RPC (Remote Procedure Call). But i noticed that this also uses a tcp/ip or udp connection.

so what the difference from using RPC to just a basic tcp/ip or udp connection to connect the client and server?

the code is completely different for example in RCP to use tcp:

      reinterpret_cast<unsigned char*>("ncacn_ip_tcp"), // Use TCP/IP protocol.
      reinterpret_cast<unsigned char*>("localhost"), // TCP/IP network address to use.
      reinterpret_cast<unsigned char*>("4747"), // TCP/IP port to use.

but in other programs (eg using WinSock) it requires a lot more code is one better than the other?

like image 499
Lisa Collins Avatar asked Mar 24 '23 16:03

Lisa Collins

1 Answers

TCP/IP and UDP are protocols for data transfer (getting data packets from here to there). The former is connection-oriented and reliable, whereas UDP is connectionless and unreliable. Neither of them care what the data actually is (a file, a webpage, a video, etc).

TCP/IP creates a connection between two endpoints and then whatever data is sent at one end is received at the other.

UDP does not have a notion of connections, it's for a one-shot "send", without guarantees about delivery.

Several higher-level network protocols are built on top of TCP/IP and UDP. For instance, HTTP (that lets you view this webpage).

RPC is a higher-level protocol, which allows one computer to execute code on another computer. The lines of code you quoted are merely setting the configuration parameters for that RPC implementation.

Summary: RPC needs a network transfer protocol (like TCP/IP) to do its job, but RPC is a higher-level protocol and fulfills a different purpose than merely sending unstructured data from one computer to another.

like image 104
Rahul Banerjee Avatar answered Apr 01 '23 21:04

Rahul Banerjee