File: es_netconnect.html

package info (click to toggle)
basic256 1.1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 24,460 kB
  • sloc: cpp: 10,148; yacc: 3,023; java: 1,091; lex: 1,051; sh: 117; xml: 33; makefile: 15
file content (148 lines) | stat: -rw-r--r-- 6,417 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
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 &quot;wait for connection on &quot; + netaddress()
netlisten 9997
print &quot;got connection&quot;
do
   while not netdata
      pause .1
      print &quot;.&quot;;
   end while
   n$ = netread
   print n$
   netwrite &quot;I got &#039;&quot; + n$ + &quot;&#039;.&quot;
until n$ = &quot;end&quot;
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 &quot;enter message?&quot;, m$
netconnect &quot;127.0.0.1&quot;, 9997
for t = 1 to 10
   pause rand
   netwrite t + &quot; &quot; + m$
   print netread
next t
netwrite &quot;end&quot;
print netread
netclose</pre>
<p>
mostrara:
</p>
<pre class="code">enter message?Hi There
I got &#039;1 Hi There&#039;.
I got &#039;2 Hi There&#039;.
I got &#039;3 Hi There&#039;.
I got &#039;4 Hi There&#039;.
I got &#039;5 Hi There&#039;.
I got &#039;6 Hi There&#039;.
I got &#039;7 Hi There&#039;.
I got &#039;8 Hi There&#039;.
I got &#039;9 Hi There&#039;.
I got &#039;10 Hi There&#039;.
I got &#039;end&#039;.</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>