Lisa Collins
Lisa Collins

Reputation: 111

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?

Upvotes: 5

Views: 8566

Answers (2)

Rahul Banerjee
Rahul Banerjee

Reputation: 2363

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.

Upvotes: 5

Dmitry Sazonov
Dmitry Sazonov

Reputation: 8994

You are talking about different notions. RPC is mechanism, TCP/UDP - way of communication. RPC concept has a lot of implementations in different languages: read wiki. TCP/UDP - is transport.

So, in your case, "using TCP/UDP" means "creating your own RPC, based on TCP/UDP". I suggest you to read about existing RPC implementations and select most acceptable, based on your task.

Upvotes: 2

Related Questions