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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<!DOCTYPE html>
<html lang="en" dir="ltr" class="no-js">
<head>
<meta charset="utf-8" />
<title>de:netconnect [BASIC 256 - Language Documentation]</title>
<link rel="stylesheet" type="text/css" href="lib/exe/cssc171c1dfe8519125bb40a349172b001a.css"/>
</head>
<body>
<div id="dokuwiki__site"><div id="dokuwiki__top" class="site dokuwiki mode_show tpl_dokuwiki ">
<div id="dokuwiki__header"><div class="pad group">
<div class="headings group">
<h1><a href="start.html" accesskey="h" title="[H]"><img src="lib/tpl/dokuwiki/images/logo.png" width="64" height="64" alt="" /> <span>BASIC 256 - Language Documentation</span></a></h1>
</div>
</div>
<div class="breadcrumbs">
<div class="youarehere"><span class="bchead">You are here: </span><span class="home"><bdi><a href="start.html" class="wikilink1" title="start">start</a></bdi></span> » <bdi><a href="de_start.html" class="wikilink1" title="de:start">de</a></bdi> » <bdi><span class="curid"><a href="de_netconnect.html" class="wikilink1" title="de:netconnect">netconnect</a></span></bdi></div>
</div>
<hr class="a11y" />
</div></div>
<div class="wrapper group">
<div id="dokuwiki__content"><div class="pad group">
<div class="pageId"><span>de:netconnect</span></div>
<div class="page group">
<div id="dw__toc">
<h3 class="toggle">Table of Contents</h3>
<div>
<ul class="toc">
<li class="level2"><div class="li"><a href="de_netconnect.html#netconnect">NetConnect</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="de_netconnect.html#format">Format</a></div></li>
<li class="level3"><div class="li"><a href="de_netconnect.html#description">Description</a></div></li>
<li class="level3"><div class="li"><a href="de_netconnect.html#example">Example</a></div></li>
<li class="level3"><div class="li"><a href="de_netconnect.html#see_also">See Also</a></div></li>
<li class="level3"><div class="li"><a href="de_netconnect.html#new_to_version">New To Version</a></div></li>
</ul></li>
</ul>
</div>
</div>
<h2 class="sectionedit1" id="netconnect">NetConnect</h2>
<div class="level2">
</div>
<h3 class="sectionedit2" id="format">Format</h3>
<div class="level3">
<p>
<strong>netconnect</strong> <em>server_name</em>, <em>port_number</em><br/>
<strong>netconnect</strong> ( <em>server_name</em>, <em>port_number</em> )<br/>
<strong>netconnect</strong> <em><a class="explain" href="de_netconnect.html">socket_number</a></em>, <em>server_name</em>, <em>port_number</em><br/>
<strong>netconnect</strong> ( <em><a class="explain" href="de_netconnect.html">socket_number</a></em>, <em>server_name</em>, <em>port_number</em> )
</p>
</div>
<h3 class="sectionedit3" id="description">Description</h3>
<div class="level3">
<p>
Open a network connection (client) to a server. The IP address or host name of a server are specified in the <em>server_name</em> argument, and the specific network port number in the <em>port_number</em> argument. If <em><a class="explain" href="de_netconnect.html">socket_number</a></em> is not specified socket number zero (0) will be used.
</p>
</div>
<h3 class="sectionedit4" id="example">Example</h3>
<div class="level3">
<p>
Open two instances of BASIC-256 on a single computer. Paste the “server” code into one and the “client” code into the other. Run the server first and the client second. You can see how the messages are sent back and forth between the two different processes.
</p>
</div>
<h4 id="server_code">Server Code</h4>
<div class="level4">
<pre class="code"># get a message and send back success
print "wait for connection"
netlisten 9997
print "got connection"
do
while not netdata
pause .1
print ".";
end while
n$ = netread
print n$
netwrite "I got '" + n$ + "'."
until n$ = "end"
netclose</pre>
<p>
will display
</p>
<pre class="code">wait for connection
got connection
.1 Hi There
....2 Hi There
........3 Hi There
..........4 Hi There
.....5 Hi There
.......6 Hi There
....7 Hi There
..........8 Hi There
....9 Hi There
.....10 Hi There
.end</pre>
</div>
<h4 id="client_code">Client Code</h4>
<div class="level4">
<pre class="code"># have the user enter a message and send it to the server
input "enter message?", m$
netconnect "127.0.0.1", 9997
for t = 1 to 10
pause rand
netwrite t + " " + m$
print netread
next t
netwrite "end"
print netread
netclose</pre>
<p>
will display
</p>
<pre class="code">enter message?Hi There
I got '1 Hi There'.
I got '2 Hi There'.
I got '3 Hi There'.
I got '4 Hi There'.
I got '5 Hi There'.
I got '6 Hi There'.
I got '7 Hi There'.
I got '8 Hi There'.
I got '9 Hi There'.
I got '10 Hi There'.
I got 'end'.</pre>
</div>
<h3 class="sectionedit5" id="see_also">See Also</h3>
<div class="level3">
<p>
<a href="de_netclose.html" class="wikilink1" title="de:netclose">NetClose</a>, <a href="de_netdata.html" class="wikilink1" title="de:netdata">NetData</a>, <a href="de_netlisten.html" class="wikilink1" title="de:netlisten">NetListen</a>, <a href="de_netread.html" class="wikilink1" title="de:netread">NetRead</a>, <a href="de_netwrite.html" class="wikilink1" title="de:netwrite">NetWrite</a>
</p>
</div>
<h3 class="sectionedit6" id="new_to_version">New To Version</h3>
<div class="level3">
<p>
0.9.6.31
</p>
</div>
</div>
<div class="docInfo"><bdi>de/netconnect.txt</bdi> · Last modified: 2011/03/29 11:56 (external edit)</div>
</div></div>
<hr class="a11y" />
</div>
<div id="dokuwiki__footer"><div class="pad">
<div class="license">Except where otherwise noted, content on this wiki is licensed under the following license: <bdi><a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="urlextern">CC Attribution-Share Alike 3.0 Unported</a></bdi></div>
</div></div>
</div></div>
<div id="screen__mode" class="no"></div>
</body>
</html>
|