Socket options: a summary - PowerPoint PPT Presentation

About This Presentation
Title:

Socket options: a summary

Description:

Socket options: a summary Tcp options, ip options and general socket options can be examined and sometimes modified. getsockopt, setsockopt fcntl – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 8
Provided by: wfa7
Learn more at: https://www.oocities.org
Category:

less

Transcript and Presenter's Notes

Title: Socket options: a summary


1
  • Socket options a summary
  • Tcp options, ip options and general socket
    options can be examined and sometimes modified.
  • getsockopt, setsockopt
  • fcntl
  • Ioctl
  • include ltsys/socket.hgt
  • int getsockopt (int sockfd, int level, int
    optname, void optval, socklen_t optlen)
  • Int setsockopt(int sockfd, int level, int
    optname, const void optval, socklen_t optlen)

2
  • include ltsys/socket.hgt
  • int getsockopt (int sockfd, int level, int
    optname, void optval, socklen_t optlen)
  • Int setsockopt(int sockfd, int level, int
    optname, const void optval, socklen_t optlen)
  • Level includes general socket option (SOL_SOCKET)
    and protocol-specific option (IP, TCP, etc).
  • Option value can be of different types int,
    in_addr, timeval, ---- that is why we use the
    void pointer.

3
  • General socket options (level SOL_SOCKET)
  • Optnames
  • SO_BROADCAST(int) permit sending broadcast
    datagram
  • SO_DEBUG for debugging purpose
  • SO_DONROUTE used by routing daemon to make sure
    a packet goes through a certain interface.
  • SO_ERROR can only be got (not set), reset the
    error
  • SO_KEEPALIVE for TCP only, automatic send
    keepalive message when inactive for 2 hours (can
    be modified).
  • SO_LINGER for TCP only, determines the behavior
    when a close is called.
  • SO_OOBINLINE put out of band data in the normal
    input queue.
  • SO_RCVBUF, SO_SNDBUF send and receive buffer
    size.

4
  • General socket options (level SOL_SOCKET)
  • Optnames
  • SO_RCVLOWAT, SO_SENDLOWAT low watermark affect
    the select system call
  • SO_RCVTIMEO, SO_SNDTIMEO inherent timeout time
    (disable by default)
  • SO_REUSEADDR Allows the port to be reused all
    server should do this to be restart immediately
  • SO_TYPE socket type? SOCK_STREAM and SOCK_DGRAM.
  • SO_USELOOPBACK sending socket gets a copy?

5
  • IP options
  • Allows packets sent through a socket to have
    certain behavior, e.g source routing
  • Level IPPROTO_IP
  • Optnames (manipulating IP header fields)
  • IP_HDRINCL
  • IP_OPTIONS
  • IP_RECVDSTADDR
  • IP_RECVIF
  • IP_TOS
  • IP_TTL

6
  • IP options
  • Level IPPROTO_IP
  • Optnames (IP MULTICAST related)
  • IP_MULTICAST_IF
  • IP_MULTICAST_TTL
  • IP_MULTICAST_LOOP
  • IP_ADD_MEMBERSHIP
  • IP_DROP_MEMBERSHIP

7
  • TCP options
  • Level IPPROTO_TCP
  • Optnames
  • TCP_KEEPALIVE set the time
  • TCP_MAXRT maximum retransmission time
  • TCP_MAXSEG maximum segment size
  • TCP_NODELAY wait to ack or not (enable)
  • TCP_STDURG where is the urgent pointer.
  • See example1.c
Write a Comment
User Comments (0)
About PowerShow.com