Reputation: 1
Any client socket program(C) over TCP/IP looks like,
/* Socket creation */ sockfd = socket(AF_INET, SOCK_STREAM, 0); /* Do nothing for dynamic address assignment to that client socket */ /* Identify the server, we use to send a request for connection */ bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(8000); inet_pton(AF_INET, serv_ip, &servaddr.sin_addr); /* Connect request to listening socket of server */ ret_val = connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); /* * Communication code ================== Here comes the code for application layer protocol using read() & write() call that follow FTP, HTTP, SMTP specific rules. * */
Any server socket program(C) over TCP/IP looks like,
/* Create listen socket */ listfd = socket(AF_INET, SOCK_STREAM, 0); /* Assign protocol family(AF_INET) & address to that socket */ bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(8004); retval = bind(listfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); /* Enable the communication on that socket */ listen(listfd, 5); /* with a specific server model(iterative/threaded/multiprocess/..) accept client request */ connfd = accept(listfd, (struct sockaddr *) &cliaddr, &clilen); /* * Communication code ================== Here comes the code for application layer protocol using read() & write() call that follow FTP, HTTP, SMTP specific rules. * */
Early host-to-host protocols focussed on human-to-computer communications Ex: Email 1971, FTP and interoperable Telnet: 1973
There was interest in app-to-app protocol - RFC 707 that describes the manner in which a networked procedure call to be done.
RPC is the transfer of a data structure from client side stub to server side stub via libnsl.so.1
, in ansi C world(say). Data structure
could hold a message for add operation(say), as shown below,
-------------
| proc: "add" |
-------------
| int: val(i) |
-------------
| int: val(j) |
-------------
Typical flow of an RPC for a remote add(i, j)
operation,
Client & server can differ in data representations(Big endian & Little endian). The external data representation (add_xdr.c
) is an data abstraction needed for machine independent communication.
Is RPC, a machine independent communication?
In RPC world, Does packet handling code between client stub & server stub behave similar to client socket & server socket? with the difference in communication code carrying a data structure that holds procedure information add(i, j)
Upvotes: 0
Views: 1387
Reputation: 15172
RPC is machine-independent, in that 32-bit and 64-bit systems can communicate, it's not as interoperable as pure sockets between different OSes, as the two sides have to agree on a lot more details.
RPC works over transports between endpoints, some of which are not even representible as sockets (local memory as an example).
You can read about RPC at https://msdn.microsoft.com/en-us/library/windows/desktop/aa373935(v=vs.85).aspx
RPC code does look quite different from socket code in that RPCs in the calling code look like any other function, it is only in those (usually tool-generated) functions that the data is bundled for transport.
Upvotes: 1