Return-Path: william@bourbon.usc.edu Delivery-Date: Thu Nov 6 16:41:56 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id mA70fu07011957 for ; Thu, 6 Nov 2008 16:41:56 -0800 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id mA70ZsGO018848 for ; Thu, 6 Nov 2008 16:35:54 -0800 Message-Id: <200811070035.mA70ZsGO018848@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Basic Socket Programming Date: Thu, 06 Nov 2008 16:35:54 -0800 From: Bill Cheng Someone wrote: > I have a question regarding the Basics of Socket Programming. > -> > We know that the server side of the socket listens on a particular which > is then approached for connection by the client side. > Let us just consider the server side of the socket. > Whenever the server accepts a connection, it generates a new socket > descriptor for that connection and continues to listen for new connections. > I would like to know that in addition to the socket descriptor, does it > also get a new temporary port to which all future messages for that > connection are assigned or does it keep using the same port it was > listening to and the connections are separated according to the sockfd? It keeps using the same port. Each socket file descriptor is associated with a separate *connection*. A connection is uniquely defined by the 4-tuple: (Host_A_IP, Host_A_Port, Host_B_IP, Host_B_Port). So, in the case you are talking about several connection may have the same (Host_A_IP, Host_A_Port), but the corresponding (Host_B_IP, Host_B_Port) will all be different. -- Bill Cheng // bill.cheng@usc.edu