Sockets API - PowerPoint PPT Presentation

About This Presentation
Title:

Sockets API

Description:

Sockets API Overview Sockets with UDP Sockets with TCP Fast Sockets (Fast UDP) IP Multicasting Sockets Overview WHAT IT IS: Used by applications to send and receive ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 11
Provided by: AlWil6
Category:
Tags: api | igmp | sockets

less

Transcript and Presenter's Notes

Title: Sockets API


1
Sockets API
  • Overview
  • Sockets with UDP
  • Sockets with TCP
  • Fast Sockets (Fast UDP)
  • IP Multicasting

2
Sockets Overview
  • WHAT IT IS
  • Used by applications to send and receive data
    over TCP/IP networks
  • WHAT IT DOES
  • Supports UDP and TCP protocols
  • Sends and receives data between applications
  • SET-UP CONDITIONS
  • Socket() call creates communications endpoints
  • Bind() links a network address to the socket
  • Other calls depend on the protocol

3
Socket-Layer Protocols
  • Application Level Network Communication Protocols
  • Ride on Top of Either TCP/IP for Guaranteed
    Delivery or UDP/IP for Minimizing Network Traffic
    (not Guaranteed)
  • Inconspicuous Communication for Security


INTERNET
Socket
Socket Connection
4
Possible Socket Implementations
TCP Connection
Server
Client
Socket Connection
Client creates socket, requests connection on
specific IP port. Server must have been passively
listening on that port.
5
Sockets Flow - UDP
Device 1
Device 2
Create
Create
Bind
Bind
SendTo
SendTo
NETWORK
RecvFrom
RecvFrom
6
Sockets Flow - TCP
Client
Server
Create
Create
(Associate Socket with own IP addr, port)
Bind
Bind
Connect
Listen
NETWORK
Accept
Send
Send
Recv
Recv
7
Example API call
include ltsockapi.hgt
  • Declaration
  • int connect(int socket_descriptor,
  • struct sockaddr_in ptr2Inet_socket_addr_struct,
    int addrlen)
  • Establish Connection
  • / Setup the server's sockaddr_in struct /
  • bzero(serverAddress, sizeof(serverAddress))
  • serverAddress.sin_family AF_INET
  • serverAddress.sin_port htons(13)
  • serverAddress.sin_addr.s_addr
    htonl(0xC75CBA53) / 199.92.186.83 /
  • int rc (connect(69, serverAddress,
    sizeof(serverAddress))
  • Return value
  • 0 if successful, otherwise -1.

8
Fast UDP (Fast Sockets)
  • Socket-like API that bypasses most of the stack
  • Advantages of Fast UDP API performance -
    potentially double the data rate
  • Advantages of Normal Sockets API portable,
    richer API, TCP support
  • Utilizes a different set of API calls

9
Fast UDP vs. Standard Socket APIs
  • Standard
  • accept
  • bind
  • connect
  • closesocket
  • connect
  • getpeername
  • gGetsockname
  • getsockopt
  • listen
  • recv
  • recvfrom
  • send
  • sendto
  • setsocketopt
  • shutdown
  • socket
  • Fast UDP
  • fBind
  • fGetBuf
  • fSendTo
  • fSockInit
  • fSocket
  • fSocketClose

10
IP Multicasting
  • NETOS TCP/IP supports Level 2 IP multicast as
    defined by RFC 1112, which includes sending and
    receiving IP multicast packets and implementation
    of the Internet Group Membership Protocol (IGMP)
    V1.
  • To enable a static interface to have multicast
    capability, the n_mcastlist field of the
    netstatic entry to point be set to a call back
    function, mcastlist. The function mcastlist is
    defined in the file narmenet.c (in the src\bsp
    directory).
  • If n_mcastlist field of a static interface be set
    to NULL, that interface won't be able to
    send/receive multicast packets.
  • The setsockopt() function is used to add/delete
    memberships and set multicast options for a
    particular socket.
Write a Comment
User Comments (0)
About PowerShow.com