www.beck-ipc.com

@CHIP-RTOS - Programming client server applications


    IPC@CHIP® Documentation Index

Client-Server

Here is a short description for programming client/server applications with the TCP/IP API.

The most often used methods for programming TCP/IP applications are client or server applications.   The term server applies to any process or program that offers a service that can be reached over the network.   Servers accept request that arrive over the network, perform their service, and return the result to the requester (client).

An example for the simplest service is the standard echo server application.   The server echoes the received data over the network back to the requester.   A process becomes a client when its sends a request to a server and waits for an answer.   The client-server model is the standard model for interprocess communication.

A TCP/IP stack provides two different methods for client-server connections, UDP and TCP.

1) UDP protocol:

This protocol realizes connectionless communication between a client and server, based on sending and receiving of single datagrams.

TCP/IP API calls used by a UDP client:

  • opensocket() - Open a socket
  • sendto() Send an outgoing datagram using a prerecorded endpoint address.
  • recvfrom() Receive the next incoming datagram and record its source endpoint address.
  • closesocket() Close the socket


    TCP/IP API calls used by a UDP server:

  • opensocket() - Open a socket
  • recvfrom() Receive the next incoming datagram and record its source endpoint address.
  • sendto() Send an outgoing datagram using a prerecorded endpoint address.


    2) TCP protocol:

    The TCP protocol is a connection- and byte stream-oriented protocol.

    TCP/IP API calls used by a TCP client:

  • opensocket() - Open a socket
  • connect() Connect to a remote peer
  • send() Send an outgoing stream of characters
  • recv() Receive an incoming stream of characters
  • closesocket() Close the socket

    TCP/IP API calls used by a TCP server:

  • opensocket() - Open a socket
  • bind() Bind a socket, assign an address to an unnamed socket
  • listen() Place the socket in a passive mode
  • accept() Accept the next incoming connection
  • recv() Receive an incoming stream of characters
  • send() Send an outgoing stream of characters
  • closesocket() Close the socket



    Examples with source code for programming UDP and TCP echo client/server applications can be found at www.beck-ipc.com.

    Note:
    All program examples are built with Beck C-Library functions declared in the library header files TCPIP.H and TCPIPAPI.H.




    End of document