Network Programming PartII

Network Programming PartII

image-20221025212319689

Socket Interface

This giant block diagram shows all the activities invloved in setting up and running both a server and a client.

The idead is you need to the server needs to fire up .You can’t contact the server until the server exists.

A server begins on a machine and then accepts a connection request from a client.

Each end looks like reading and writing a file.

Once the client is done with whatever it’s trying to get,it will disconnect.Then the listening server will detect this by receiving an end of file when it attempts to read from the client,then it will close the connection.

This it’s not going to shut down at this point ,it’s just going to return back and accept new connection request.This is what’s known as an interactive server,which can only handle a single client at a time.

The first step between client and server is very messy relatively new api call getaddrinfo.

It contains a lot of other sort of individual protocols.

It lets you sort of go forward from a domain name to a IP address and go backward from an IP address back to domain name.

Recall

Generic socket address

  • For address arguments to connect,bind,and accept

  • Necessary only because C did not have generic (void *)Pointers when the sockets interface was designed

  • For casting convenience,we adopt the Stevens convention:

    1
    2
    3
    4
    5
    typedef struct sockaddr SA;
    struct sockaddr{
    uint16_t sa_family; //protocol family
    char as_data[14];//Address data
    }

Network Programming PartII
http://example.com/2022/10/25/Network-Programming-PartII/
Author
WYX
Posted on
October 25, 2022
Licensed under