Socket -> A communication mechanism that allows client and server - TopicsExpress



          

Socket -> A communication mechanism that allows client and server to communicate with each other either locally on single machine , or across networks. A Generic Socket Address Structure ---------------------------------------------- A socket address structure is always passed by reference when passed as an argument to any socket functions.That means many of the networking system calls require a pointer to a socket address structure as an argument. struct sockaddr { unsigned char sa_len ; /* specifies total length */ sa_family_t sa_family; /* specifies address family */ char sa_data[14]; /* specifies variable length address */ }; struct in_addr { in_addr_t s_addr; /* specifies IPv4 address */ }; struct sockaddr_un { sa_family_t sun_family; /* specifies AF_UNIX(Unix Internal Protocols) address family */ char sun_path[108]; }; struct sockaddr_in { sa_family_t sin_family ; /* specifies AF_INET(Intenet Protocols) address family */ in_port_t sin_port ; /* port number */ struct in_addr sin_addr ; /* IPv4 address */ }; struct sockaddr is a generic definition. Its used by any socket function that requires an address. struct sockaddr_un (a Unix sockets address) is a specific kind of address family(AF_UNIX). The more commonly seen struct sockaddr_in (an Internet socket address) is another specific kind of address family(AF_INET). The definition of these structures are present in header file
Posted on: Mon, 07 Jul 2014 12:45:40 +0000

Trending Topics



Recently Viewed Topics




© 2015