aboutsummaryrefslogtreecommitdiff
path: root/man/man3/udpread.html
blob: e8f0d37b43be40140b2bf12b6c37b5008d439f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<head>
<title>udpread(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>UDPREAD(3)</b><td align=right><b>UDPREAD(3)</b>
<tr><td width=20><td colspan=2>
    <br>
<p><font size=+1><b>NAME     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    udpread, udpwrite &ndash; read and write UDP packets<br>
    
</table>
<p><font size=+1><b>SYNOPSIS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>#include &lt;u.h&gt; 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>#include &lt;libc.h&gt; 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>#include &lt;ip.h&gt; 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>typedef struct Udphdr Udphdr;<br>
    </font></tt>struct Udphdr<br>
    {<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        uchar &nbsp;&nbsp;&nbsp;raddr[IPaddrlen];/* remote address and port */<br>
        uchar &nbsp;&nbsp;&nbsp;laddr[IPaddrlen];/* local address and port */<br>
        uchar &nbsp;&nbsp;&nbsp;rport[2];<br>
        uchar &nbsp;&nbsp;&nbsp;lport[2];<br>
        
    </table>
    };<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <tt><font size=+1>long &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;udpread(int fd, Udphdr *hdr, void *data, long n)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>long udpwrite(int fd, Udphdr *hdr, void *data, long n)<br>
    </font></tt>
</table>
<p><font size=+1><b>DESCRIPTION     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <i>Udpread</i> and <i>udpwrite</i> read and write UDP packets from the UDP network
    connection established on file descriptor <i>fd</i>. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Udpread</i> reads at most <i>n</i> bytes of packet body into <i>data ,</i> stores
    the header in <i>hdr</i>, and returns the number of bytes stored in <i>data</i>.
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Udpwrite</i> writes the <i>n</i> bytes stored in <i>data</i> in a UDP packet with
    header <i>hdr</i>. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    Note that the <tt><font size=+1>Udphdr</font></tt> frames the addresses as local and remote
    instead of source and destination. Thus the <i>hdr</i> filled in for
    a packet read by <i>udpread</i> can be used unchanged in <i>udpwrite</i> to
    send a response back to the sender of the original packet.<br>
    
</table>
<p><font size=+1><b>SOURCE     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>/usr/local/plan9/src/lib9/udp.c<br>
    </font></tt>
</table>
<p><font size=+1><b>SEE ALSO    </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <a href="../man3/ip.html"><i>ip</i>(3)</a><br>
    
</table>

<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>