Comments
#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