tailieunhanh - Internetworking with TCP/IP- P47
Internetworking with TCP/IP- P47: TCP/IP has accommodated change well. The basic technology has survived nearly two decades of exponential growth and the associated increases in traffic. The protocols have worked over new high-speed network technologies, and the design has handled applications that could not be imagined in the original design. Of course, the entire protocol suite has not remained static. New protocols have been deployed, and new techniques have been developed to adapt existing protocols to new network technologies | Sec. Connecting Sockets To Destination Addresses 419 Argument socket is the integer descriptor of the socket to connect. Argument destaddr is a socket address structure that specifies the destination address to which the socket should be bound. Argument addrlen specifies the length of the destination address measured in bytes. The semantics of connect depend on the underlying protocols. Selecting the reliable stream delivery service in the PFJNET family means choosing TCP. In such cases connect builds a TCP connection with the destination and returns an error if it cannot. In the case of connectionless service connect does nothing more than store the destination address locally. Sending Data Through A Socket Once an application program has established a socket it can use the socket to transmit data. There are five possible functions from which to choose send sendto sendmsg write and writev. Send write and writev only work with connected sockets because they do not allow the caller to specify a destination address. The differences between the three are minor. Write takes three arguments write socket buffer length Argument socket contains an integer socket descriptor write can also be used with other types of descriptors . Argument buffer contains the address of the data to be sent and argument length specifies the number of bytes to send. The call to write blocks until the data can be transferred . it blocks if internal system buffers for the socket are full . Like most system calls write returns an error code to the application calling it allowing the programmer to know if the operation succeeded. The system call writev works like write except that it uses a gather write form making it possible for the application program to write a message without copying the message into contiguous bytes of memory. Writev has the form writev socket iovector vectorlen Argument iovector gives the address of an array of type iovec that contains a sequence of pointers to
đang nạp các trang xem trước