Sockets Basics - PowerPoint PPT Presentation

About This Presentation
Title:

Sockets Basics

Description:

Bind. sendto. recvfrom. Client. Basic functions ... Bind (int sockfd, struct sockaddr *myaddr, int addrlen) : assigns a name to an ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 12
Provided by: ece9
Category:
Tags: basics | bind | pipes | sockets

less

Transcript and Presenter's Notes

Title: Sockets Basics


1
Sockets Basics
  • Conectionless Protocol

2
Today
  • IPC
  • Sockets
  • Basic functions
  • Handed code
  • Q A

3
Interprocess Communication
  • Mechanism to allow processes to communicate and
    to synchronize their actions
  • Within the same system or different systems
  • Best provided by messaging systems (no shared
    variables)

4
IPC types
  • Pipes
  • FIFOs
  • Streams and messages
  • Message queues, semaphores and shared memory
    (system V)
  • Sockets and TLI

5
Sockets
  • Communication among processes in the same system
    (pipes) and different systems
  • Characteristics
  • Unique address
  • Domain dependent
  • Types
  • Stream
  • Sequenced
  • Datagram
  • Raw
  • Connectionless Vs connection oriented

6
Connectionless Oriented
Server
Client
Socket
Socket
Bind
Bind
recvfrom
Blocks until data received from a client
sendto
Process request
sendto
recvfrom
7
Basic functions
  • socket (int family, int type, int protocol)
    defines the socket
  • Address family UNIX, internet, Xerox NS, IMP
  • Type stream, datagram, raw, sequenced
  • Protocol argument specify protocol (tcp, udp,
    icmp, etc)
  • Returns a socket file descriptor

8
Basic functions cont
  • Bind (int sockfd, struct sockaddr myaddr, int
    addrlen) assigns a name to an unnamed socket
    (this is my adddress and any messages received
    for this address are to be given to me)
  • sockfd socket file descriptor
  • struct sockaddr protocol specific address
    (family, port, address - netid)
  • addrlen size of the structure
  • returns error if so

9
Basic functions cont
  • sendto (int sockfd, char buff, int nbytes, int
    flags, struct sockaddr to, int addrlen) send
    message
  • recvfrom (int sockfd, char buff, int nbytes, int
    flags, struct sockaddr to, int addrlen)
    receive message
  • buff message
  • nbytes length of the message

10
Handed code
  • Init_socket
  • send_packet
  • receive_packet
  • get_addr_byname

11
Questions and Answers
Write a Comment
User Comments (0)
About PowerShow.com