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

2

5

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?

Exogenous answered 9/4, 2013 at 10:39 Comment(0)
E
5

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.

Earleneearley answered 9/4, 2013 at 11:0 Comment(5)
so RPC needs TCP/IP and can't be used with UDP?Exogenous
@LisaCollins RPC does not require TCP/IP ... it requires a transport layer. that could be TCP/IP, but it also could be Unix Socket or something else that transport the data from A to B. depending on the requirements a certain protocol should used. TCP/IP is e.g. used when a requirement is that requests and responses must be received and should not be lost.Chromatolysis
so what does RPC do that a TCP/IP or UDP connection can't do?Exogenous
RPC lets code on computer A call a function on computer B. TCP/IP is one way for it to send this request across.Earleneearley
This topic is old but if anyone has this kind of question, here is an image that can help you understand : miro.medium.com/max/631/1*S0ZaTC0BuYuEaPcgPi_5bg.jpeg The TCP/IP model is the closest from reality (OSI is an abstract specification) : RPC are "Application" type (the link is not understood by SO, just copy/paste...)Catamenia
F
2

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.

Folger answered 9/4, 2013 at 11:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.