Migrated from tutorial-sockets v4
This commit is contained in:
parent
4cc3d25850
commit
2938610992
|
@ -1,11 +1,10 @@
|
||||||
The first thing you need to do is import the sockets module<br>
|
The first thing you need to do is import the sockets module<br>
|
||||||
<code>import sockets</code><br>
|
<code>import sockets</code><br>
|
||||||
Then you need to create and initialize a TSocket object<br>
|
Then you need to create and initialize a TSocket object<br>
|
||||||
<code><nowiki>var s: TSocket = socket()</nowiki></code><br>
|
<code>var s: TSocket = socket()</code><br>
|
||||||
After that you can use <code>s.connect("addr", TPort(80))</code> to connect to a server<br>
|
After that you can use <code>s.connect("addr", TPort(80))</code> to connect to a server<br>
|
||||||
Once you connect to a server, you can send and receive messages to/from the server by using <code>s.send("Message")</code> to send, and <code>s.recv()</code> to receive.
|
Once you connect to a server, you can send and receive messages to/from the server by using <code>s.send("Message")</code> to send, and <code>s.recv()</code> to receive.
|
||||||
== Examples ==
|
|
||||||
=== IRC Bot ===
|
|
||||||
<pre><nowiki>
|
<pre><nowiki>
|
||||||
import sockets, strutils
|
import sockets, strutils
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue