Download presentation
Presentation is loading. Please wait.
Published byTamsin Wilkerson Modified over 8 years ago
1
CS 447 Networks and Data Communication Server-Process Organization IP address and SockAddr_In Data Structure Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu Socekt-2/000
2
Socekt-2/001 Project Phase 1: Suggested server organization CS447 - Computer and Data Communication socket_id = socket ( ……. ): void main (void) { bind (socket_id, ……. ): listen (socket_id, ……. ): duplicated_socket = accept (socket_id, ……. ): recv (duplicated_socket, ……. ): send (duplicated_socket, ……. ): closesocket (duplicated_socket): int socket_id int duplicated_socket while (TRUE) { Not “socket_id” but “duplicated_socket” } Infinite loop
3
Socekt-2/002 CS447 - Computer and Data Communication socket_id = socket ( ……. ): void main (void) { bind (socket_id, ……. ): listen (socket_id, ……. ): struct sockaddr_in server_addr; /* Server Internet address */ struct sockaddr_in client_addr; /* Client address */ Project Phase 1: Suggested server organization (continued) We are going to create two “sockaddr_in” data structures duplicated_socket = accept (socket_id, ……. ): “sockaddr_in” structure Hold IP address and port
4
Socekt-2/003 CS447 - Computer and Data Communication socket_id = socket ( ……. ): void main (void) { bind (socket_id, (struct sockaddr *) &server_addr, ….. ): listen (socket_id, ……. ): struct sockaddr_in server_addr; /* Server Internet address */ struct sockaddr_in client_addr; /* Client address */ Project Phase 1: Suggested server organization (continued) duplicated_socket = accept (socket_id, ……. ):
5
CS447 - Computer and Data Communication Server Host Computer Network Interface Card (NIC) Network A Network B NIC IP: 146.163.147.59 IP: 24.18.210.1 server_addr.sin_family = AF_INET; /* Address Family To Be Used */ server_addr.sin_port = htons (1050); /* Port number */ server_addr.sin_addr.s_addr = htonl (146.163.147.59); /* IP address */ Socekt-2/004 Accept request only from network A
6
CS447 - Computer and Data Communication Server Host Computer Network Interface Card (NIC) Network A Network B NIC IP: 146.163.147.59 IP: 24.18.210.1 server_addr.sin_family = AF_INET; /* Address Family To Be Used */ server_addr.sin_port = htons (1050); /* Port number */ server_addr.sin_addr.s_addr = htonl (24.18.210.1); /* IP address */ Socekt-2/005 Accept request only from network B
7
CS447 - Computer and Data Communication Server Host Computer Network Interface Card (NIC) Network A Network B NIC IP: 146.163.147.59 IP: 24.18.210.1 server_addr.sin_family = AF_INET; /* Address Family To Be Used */ server_addr.sin_port = htons (1050); /* Port number */ server_addr.sin_addr.s_addr = htonl (INADDR_ANY); /* IP address */ Socekt-2/006 Accept requests from both networks
8
Socekt-2/007 CS447 - Computer and Data Communication socket_id = socket ( ……. ): void main (void) { bind (socket_id, ……. ): listen (socket_id, ……. ): struct sockaddr_in server_addr; /* Server Internet address */ struct sockaddr_in client_addr; /* Client address */ Project Phase 1: Suggested server organization (continued) duplicated_socket = accept (socket_id, (struct sockaddr *) &client_addr, …… ): IP address of a client Port# of a client
9
Socekt-2/008 CS447 - Computer and Data Communication socket_id = socket ( ……. ): void main (void) { bind (socket_id, server_addr, ….. ): listen (socket_id, ……. ): struct sockaddr_in server_addr; /* Server Internet address */ struct sockaddr_in client_addr; /* Client address */ Project Phase 1: Suggested server organization (continued) duplicated_socket = accept (socket_id, client_addr, p_client_add_size); int client_add_size = sizeof(client_addr); int * p_client_add_size = &client_add_size;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.