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>es: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="es_start.html" class="wikilink1" title="es:start">es</a></bdi> » <bdi><span class="curid"><a href="es_netconnect.html" class="wikilink1" title="es: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>es: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="es_netconnect.html#netconnect">NetConnect</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="es_netconnect.html#formato">Formato</a></div></li>
<li class="level3"><div class="li"><a href="es_netconnect.html#descripcion">Descripción</a></div></li>
<li class="level3"><div class="li"><a href="es_netconnect.html#ejemplo">Ejemplo</a></div></li>
<li class="level3"><div class="li"><a href="es_netconnect.html#ver_tambien">Ver también</a></div></li>
<li class="level3"><div class="li"><a href="es_netconnect.html#disponible_desde_la_version">Disponible desde la versión</a></div></li>
</ul></li>
</ul>
</div>
</div>
<h2 class="sectionedit1" id="netconnect">NetConnect</h2>
<div class="level2">
</div>
<h3 class="sectionedit2" id="formato">Formato</h3>
<div class="level3">
<p>
<strong>netconnect</strong> <em>NombredeServidor</em>, <em>NúmerodePuerto</em><br/>
<strong>netconnect</strong> ( <em>NombredeServidor</em>, <em>NúmerodePuerto</em> )<br/>
<strong>netconnect</strong> <em>NúmerodeSocket</em>, <em>NombredeServidor</em>, <em>NúmerodePuerto</em><br/>
<strong>netconnect</strong> ( <em>NúmerodeSocket</em>, <em>NombredeServidor</em>, <em>NúmerodePuerto</em> )
</p>
</div>
<h3 class="sectionedit3" id="descripcion">Descripción</h3>
<div class="level3">
<p>
Abre una conexión de red (cliente) con un servidor. La dirección IP o el nombre del host del servidor se especifica en el argumento <em>NombredeServidor</em>, y el número de puerto de rede en el argumento <em>NúmerodePuerto</em>. Si no se indica un <em>NúmerodeSocket</em> se utilizara el número cero (0).
</p>
</div>
<h3 class="sectionedit4" id="ejemplo">Ejemplo</h3>
<div class="level3">
<p>
Abra dos instancias de BASIC-256 en un mismo equipo. Pegue el código “servidor” en una y el código “cliente” en el otro. Ejecute en primer lugar el servidor y después el cliente. Puede verse como los mensajes son enviados de un lado a otro entre los dos procesos.
</p>
</div>
<h4 id="codigo_servidor">Código Servidor</h4>
<div class="level4">
<pre class="code"># get a message and send back success
print "wait for connection on " + netaddress()
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>
mostrará (donde xxx.xxx.xxx.xxx es la dirección IPv4 de su equipo):
</p>
<pre class="code">wait for connection on xxx.xxx.xxx.xxx
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="codigo_cliente">Código cliente</h4>
<div class="level4">
<pre class="code"># el usuario debe teclear un mensaje y enviarlo al servidor
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>
mostrara:
</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="ver_tambien">Ver también</h3>
<div class="level3">
<p>
<a href="es_netaddress.html" class="wikilink1" title="es:netaddress">NetAddress</a>, <a href="es_netclose.html" class="wikilink1" title="es:netclose">NetClose</a>, <a href="es_netdata.html" class="wikilink1" title="es:netdata">NetData</a>, <a href="es_netlisten.html" class="wikilink1" title="es:netlisten">NetListen</a>, <a href="es_netread.html" class="wikilink1" title="es:netread">NetRead</a>, <a href="es_netwrite.html" class="wikilink1" title="es:netwrite">NetWrite</a>
</p>
</div>
<h3 class="sectionedit6" id="disponible_desde_la_version">Disponible desde la versión</h3>
<div class="level3">
<p>
0.9.6.31
</p>
</div>
</div>
<div class="docInfo"><bdi>es/netconnect.txt</bdi> · Last modified: 2011/04/06 12:53 (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>
|