CSE 124 Lecture Notes - Lecture 7: Segmentation Fault

24 views2 pages

Document Summary

Options apply to different layers of the network stack: Int getsockopt ( int sockfd, int level, int optname, void *optval, socklen_t *optlen); sockfd - socket descriptor. Level - level of socket (sol_socket) optname - what it is that we want to configure? optval - actual value optlen - length of value. If we want to send large files, our buffers might be too small and we call send/recv way too many times (large overhead due to context switching!) If we have many concurrent connections, it"ll take a ton of memory, so we may also want to shrink our buffer. /* enables sockets to be immediately reused */ If (setsockopt(serv_sock, sol_socket, so_reuseaddr, &optval, sizeof(optval)) != 0 { die_system( setsockopt() failed ); If clients crash, or something happens, we don"t want to keep allocating resources to that socket, so we should close it at some point. Ssize_t sendfile ( int out_fd, int in_fd, off_t *offset, size_t count);

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers