File: Socket_8h_source.html

package info (click to toggle)
stk 4.4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 24,856 kB
  • sloc: cpp: 33,976; tcl: 2,375; sh: 2,319; ansic: 163; perl: 114; makefile: 37
file content (92 lines) | stat: -rw-r--r-- 9,062 bytes parent folder | download | duplicates (2)
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
<HTML>
<HEAD>
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<img src="princeton.gif"> &nbsp; <img src="ccrma.gif"> &nbsp; <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="links.html">Links</a> &nbsp; <a class="qindex" href="faq.html">FAQ</a> &nbsp; <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.6.2 -->
  <div class="navpath"><a class="el" href="dir_221deb9bdff892d63ed1e409450a60d2.html">include</a>
  </div>
<div class="contents">
<h1>Socket.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_SOCKET_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_SOCKET_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;Stk.h&quot;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 <span class="preprocessor">  #include &lt;sys/socket.h&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">  #include &lt;sys/types.h&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">  #include &lt;arpa/inet.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">  #include &lt;netdb.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">  #include &lt;unistd.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">  #include &lt;fcntl.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">  #include &lt;netinet/in.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">  #include &lt;netinet/tcp.h&gt;</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#elif defined(__OS_WINDOWS__)</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span>
<a name="l00019"></a>00019 <span class="preprocessor">  #include &lt;winsock.h&gt;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#endif</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="keyword">namespace </span>stk {
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="comment">/***************************************************/</span>
<a name="l00036"></a>00036 <span class="comment">/***************************************************/</span>
<a name="l00037"></a>00037 
<a name="l00038"></a><a class="code" href="classstk_1_1Socket.html">00038</a> <span class="keyword">class </span><a class="code" href="classstk_1_1Socket.html" title="STK internet socket abstract base class.">Socket</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1Stk.html" title="STK base class.">Stk</a>
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040  <span class="keyword">public</span>:
<a name="l00041"></a>00041 
<a name="l00042"></a>00042   <span class="keyword">enum</span> ProtocolType {
<a name="l00043"></a>00043     PROTO_TCP,
<a name="l00044"></a>00044     PROTO_UDP
<a name="l00045"></a>00045   };
<a name="l00046"></a>00046 
<a name="l00048"></a>00048   <a class="code" href="classstk_1_1Socket.html#a2558d3b2001c07eeae9d3e301df399fe" title="Class constructor.">Socket</a>();
<a name="l00049"></a>00049 
<a name="l00051"></a>00051   <span class="keyword">virtual</span> <a class="code" href="classstk_1_1Socket.html#a8fb79fcfba5d1438575e0fb933f8b37b" title="Class destructor.">~Socket</a>();
<a name="l00052"></a>00052 
<a name="l00054"></a>00054   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Socket.html#a816c3dfae2549db692944042821d6019" title="Close the socket.">close</a>( <span class="keywordtype">int</span> socket );
<a name="l00055"></a>00055 
<a name="l00057"></a><a class="code" href="classstk_1_1Socket.html#aeae0c6721248eecd5dae0b77ea66cb2c">00057</a>   <span class="keywordtype">int</span> <a class="code" href="classstk_1_1Socket.html#aeae0c6721248eecd5dae0b77ea66cb2c" title="Return the socket descriptor.">id</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> soket_; };
<a name="l00058"></a>00058 
<a name="l00060"></a><a class="code" href="classstk_1_1Socket.html#abe3040ecfff6ce921284c6ab4b0500a7">00060</a>   <span class="keywordtype">int</span> <a class="code" href="classstk_1_1Socket.html#abe3040ecfff6ce921284c6ab4b0500a7" title="Return the socket port number.">port</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> port_; };
<a name="l00061"></a>00061 
<a name="l00063"></a><a class="code" href="classstk_1_1Socket.html#a61375099d0d0811bf79c894587cc3724">00063</a>   <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classstk_1_1Socket.html#a61375099d0d0811bf79c894587cc3724" title="Returns true if the socket descriptor is valid.">isValid</a>( <span class="keywordtype">int</span> socket ) { <span class="keywordflow">return</span> socket != -1; };
<a name="l00064"></a>00064 
<a name="l00066"></a>00066   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Socket.html#a12f0abb799fbf7d5d2ee6364627cb6ac" title="If enable = false, the socket is set to non-blocking mode. When first created, sockets...">setBlocking</a>( <span class="keywordtype">int</span> socket, <span class="keywordtype">bool</span> enable );
<a name="l00067"></a>00067 
<a name="l00069"></a>00069   <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1Socket.html#a7938202181552306d0ea74c6c04abf4a" title="Write a buffer over the socket connection. Returns the number of bytes written or...">writeBuffer</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *buffer, <span class="keywordtype">long</span> bufferSize, <span class="keywordtype">int</span> flags = 0) = 0;
<a name="l00070"></a>00070 
<a name="l00072"></a>00072   <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1Socket.html#aa99d0f4e1c0ebae768a9f3f124364906" title="Read an input buffer, up to length bufferSize. Returns the number of bytes read or...">readBuffer</a>(<span class="keywordtype">void</span> *buffer, <span class="keywordtype">long</span> bufferSize, <span class="keywordtype">int</span> flags = 0) = 0;
<a name="l00073"></a>00073 
<a name="l00075"></a>00075   <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1Socket.html#a7938202181552306d0ea74c6c04abf4a" title="Write a buffer over the socket connection. Returns the number of bytes written or...">writeBuffer</a>(<span class="keywordtype">int</span> socket, <span class="keyword">const</span> <span class="keywordtype">void</span> *buffer, <span class="keywordtype">long</span> bufferSize, <span class="keywordtype">int</span> flags );
<a name="l00076"></a>00076 
<a name="l00078"></a>00078   <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1Socket.html#aa99d0f4e1c0ebae768a9f3f124364906" title="Read an input buffer, up to length bufferSize. Returns the number of bytes read or...">readBuffer</a>(<span class="keywordtype">int</span> socket, <span class="keywordtype">void</span> *buffer, <span class="keywordtype">long</span> bufferSize, <span class="keywordtype">int</span> flags );
<a name="l00079"></a>00079 
<a name="l00080"></a>00080  <span class="keyword">protected</span>:
<a name="l00081"></a>00081 
<a name="l00082"></a>00082   <span class="keywordtype">int</span> soket_;
<a name="l00083"></a>00083   <span class="keywordtype">int</span> port_;
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 };
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 } <span class="comment">// stk namespace</span>
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 <span class="preprocessor">#endif</span>
</pre></div></div>
<HR>

<table>
  <tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
  <tr><td>&copy;1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>

</BODY>
</HTML>