Describe Connection setup listen & accept in socket programming? shaw 26-October-2007 05:18:59 PMComments #int status = listen(sock, queuelen); status: 0 if listening, -1 if error sock: integer, socket descriptor queuelen: integer, # of active participants that can “wait” for a connection listen is non-blocking: returns immediately #int s = accept(sock, &name, &namelen); s: integer, the new socket desc. (used for data-transfer) sock: integer, the orig. socket desc. (being listened on) name: struct sockaddr, address of the active participant namelen: sizeof(name): value/result parameter must be set appropriately before call adjusted by OS upon return accept is blocking: waits for connection before returning Posted by waqasahmad Called by passive participant 1. int status = listen(sock, queuelen); - status: 0 if listening, -1 if error - sock: integer, socket descriptor - queuelen: integer, # of active participants that can “wait” for a connection - listen is non-blocking: returns immediately 2. int s = accept(sock, &name, &namelen); - s: integer, the new socket desc. (used for data-transfer) - sock: integer, the orig. socket desc. (being listened on) - name: struct sockaddr, address of the active participant - namelen: sizeof(name): value/result parameter - must be set appropriately before call - adjusted by OS upon return -accept is blocking: waits for connection before returning Posted by ceeser |
Posted: 26-October-2007 05:50:36 PM By: ceeser Called by passive participant 1. int status = listen(sock, queuelen); - status: 0 if listening, -1 if error - sock: integer, socket descriptor - queuelen: integer, # of active participants that can “wait” for a connection - listen is non-blocking: returns immediately 2. int s = accept(sock, &name, &namelen); - s: integer, the new socket desc. (used for data-transfer) - sock: integer, the orig. socket desc. (being listened on) - name: struct sockaddr, address of the active participant - namelen: sizeof(name): value/result parameter - must be set appropriately before call - adjusted by OS upon return -accept is blocking: waits for connection before returning | |
Posted: 31-December-2008 12:23:15 AM By: waqasahmad #int status = listen(sock, queuelen); status: 0 if listening, -1 if error sock: integer, socket descriptor queuelen: integer, # of active participants that can “wait” for a connection listen is non-blocking: returns immediately #int s = accept(sock, &name, &namelen); s: integer, the new socket desc. (used for data-transfer) sock: integer, the orig. socket desc. (being listened on) name: struct sockaddr, address of the active participant namelen: sizeof(name): value/result parameter must be set appropriately before call adjusted by OS upon return accept is blocking: waits for connection before returning |