How To Put A Host Program Address Together

How To Put A Host Program Address Together


  • 21 Dec, 2011

    Once a host address and port number are known then the complete process address must be put together in a form that may be used by the system calls already covered. The structures set up to allow this follow:#include <netinet/in.h>/* * Internet address (a structure for historical reasons) */struct in_addr { union {struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; struct { u_short s_w1,s_w2; } S_un_w; u_long S_addr; } S_un;#define s_addr S_un.S_addr/* can be used for most tcp & ip code */};/* * Socket address, internet style. */struct sockaddr_in { short sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8];};Filling in the fields for sockaddr_in will produce an Internet version of a socket address.

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.