System Call Return Conventions Most system calls have the same return Most system calls have the same return conventions conventions An int value >= 0 indicates success; -1 indicates An int value >= 0 indicates success; -1 indicates failure. failure. Failed calls set " Failed calls set " errno" to indicate the cause of errno" to indicate the cause of failure; perror () will print a message based on the failure; perror () will print a message based on the "errno" value. "errno" value. Here is the typical coding logic: Here is the typical coding logic: int s = socket(AF_INET, SOCK_STREAM, 0); if (s <>the port and IP address must be specified. specified. For bind(), either may be set to zero. For bind(), either may be set to zero. Specifying "sin_port" as zero requests that the Specifying "sin_port" as zero requests that the system assign a transient port. Use system assign a transient port. Use getsockname () getsockname () to find out what port number was chosen. to find out what port number was chosen. Specifying "sin_ Specifying "sin_ addr" as zero binds to all IP addr" as zero binds to all IP addresses on the host (some hosts have more than addresses on the host (some hosts have more than one). one). Client Establishes stderr port stderr port rexeccmd rexeccmd rexec rexec Primary Primary Socket Socket rexecd rexecd host. mvs server. unx host. mvs server. unx stdin/stdout/stderr Rexecd reads stdin until a null character is found, if any characters are read before the null they are interpreted as an optional secondary port address to be used for stderr...
Download C Socket Programming Tutorial II.Pdf
C Socket Programming Tutorial II
Tuesday, March 16, 2010
Labels:
C and C ++
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment