This shows you the differences between two versions of the page.
pt:netconnect [2016/01/01 22:48] |
pt:netconnect [2020/02/28 10:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== NetConnect ===== | ||
+ | ==== Formato ==== | ||
+ | **netconnect** // | ||
+ | **netconnect** ( // | ||
+ | **netconnect** // | ||
+ | **netconnect** ( // | ||
+ | |||
+ | ==== Descrição ==== | ||
+ | Abre uma ligação em rede (client) com um servidor. | ||
+ | |||
+ | ==== Exemplo ==== | ||
+ | Abra duas instâncias de Basic 256 no mesmo computador. | ||
+ | === Servidor === | ||
+ | < | ||
+ | # 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$ | ||
+ | | ||
+ | until n$ = " | ||
+ | netclose | ||
+ | </ | ||
+ | will display (where xxx.xxx.xxx.xxx is the IPv4 address of your computer) | ||
+ | < | ||
+ | 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 | ||
+ | </ | ||
+ | |||
+ | === Cliente === | ||
+ | < | ||
+ | # have the user enter a message and send it to the server | ||
+ | input "enter message?", | ||
+ | netconnect " | ||
+ | for t = 1 to 10 | ||
+ | pause rand | ||
+ | | ||
+ | print netread | ||
+ | next t | ||
+ | netwrite " | ||
+ | print netread | ||
+ | netclose | ||
+ | </ | ||
+ | will display | ||
+ | < | ||
+ | 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 ' | ||
+ | </ | ||
+ | |||
+ | ==== Ver também ==== | ||
+ | [[NetAddress|NetAddress]], | ||
+ | |||
+ | ==== Desde ==== | ||
+ | 0.9.6.31 |