Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Connect for Kids

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 140 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

udp



SYNOPSIS

       #include <sys/socket.h>
       #include <netinet/in.h>
       udp_socket = socket(PF_INET, SOCK_DGRAM, 0);


DESCRIPTION

       This  is  an  implemention  of  the User Datagram Protocol
       described in RFC768. It implements a connectionless, unre­
       liable  datagram packet service.  Packets may be reordered
       or duplicated before they arrive. UDP generates and checks
       checksums to catch transmission errors.

       When  a  UDP  socket  is  created,  its  local  and remote
       addresses are unspecified.  Datagrams can be sent  immedi­
       ately  using sendto(2) or sendmsg(2) with a valid destina­
       tion address as an argument.  When connect(2) is called on
       the  socket  the  default  destination  address is set and
       datagrams can now be sent using send(2) or write(2)  with­
       out specifying an destination address.  It is still possi­
       ble to send to other destinations by passing an address to
       sendto(2)  or sendmsg(2).  In order to receive packets the
       socket can be bound to an local  address  first  by  using
       bind(2).   Otherwise  the  socket layer will automatically
       assign a free local port  out  of  the  range  defined  by
       net.ipv4.ip_local_port_range   and   bind  the  socket  to
       INADDR_ANY.

       All receive operations return only one packet.   When  the
       packet  is  smaller  than the passed buffer only that much
       data is returned, when it is bigger the  packet  is  trun­
       cated  and  the MSG_TRUNC flag is set.  MSG_WAITALL is not
       supported.

       IP options may  be  sent  or  received  using  the  socket
       options  described  in  ip(7).  They are only processed by
       the kernel when the appropriate  sysctl  is  enabled  (but
       still  passed to the user even when it is turned off). See
       ip(7).

       When the MSG_DONTROUTE flag is set on sending the destina­
       tion  address must refer to an local interface address and
       the packet is only sent to that interface.

       UDP fragments a packet when its total length  exceeds  the
       interface MTU (Maximum Transmission Unit).  A more network
       friendly alternative is  to  use  path  MTU  discovery  as
       described in the IP_PMTU_DISCOVER section of ip(7).


ADDRESS FORMAT

       UDP  uses the IPv4 sockaddr_in address format described in
       ip(7).
       errors only when the socket has been connected (except for
       EPROTO and EMSGSIZE).  It is better to  fix  the  code  to
       handle   errors  properly  than  to  enable  this  option.
       Locally generated errors are always passed.

       When the IP_RECVERR  option  is  enabled  all  errors  are
       stored  in  the  socket error queue and can be received by
       recvmsg(2) with the MSG_ERRQUEUE flag set.


IOCTLS

       These ioctls can be accessed using ioctl(2).  The  correct
       syntax is:

              int value;
              error = ioctl(tcp_socket, ioctl_type, &value);

       SIOCINQ
              Gets  a  pointer to an integer as argument. Returns
              the size of the next pending datagram in the  inte­
              ger in bytes, or 0 when no datagram is pending.

       SIOCOUTQ
              Returns  the number of data bytes in the local send
              queue. Only supported with Linux 2.4 and above.

       In addition all ioctls documented in ip(7)  and  socket(7)
       are supported.


ERRORS

       All  errors  documented  for  socket(7)  or  ip(7)  may be
       returned by a send or receive on a UDP socket.

       ECONNREFUSED No receiver was associated with the  destina­
       tion  address.   This might be caused by a previous packet
       sent over the socket.


VERSIONS

       IP_RECVERR is a new feature in Linux 2.2.


CREDITS

       This man page was written by Andi Kleen.


SEE ALSO

       ip(7), socket(7), raw(7)

       RFC768 for the User Datagram Protocol.
       RFC1122 for the host requirements.
       RFC1191 for a description of path MTU discovery.

  




Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can help in many different ways.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.09 Seconds