Web+ Tutorial

Previous

  Contents   Next

Lesson 8.2 - TCP/IP Communication using Sockets

Description
A socket is the interface by which a program communicates with another host machine. Before your Web+ scripts can communicate with another computer, you must open a socket to that computer. Then you may communicate with it by sending and receiving text.

Protocol ports are numbers associated with various protocols used for transferring information from one host to another. By supplying a port number you can tell the remote machine what protocol you intend to use. The way a remote machine responds to your communication depends on what communication protocol you use.

Web+ allows you to open and close sockets and to send and receive text using open sockets.

Syntax
<webSocketOpen name = name host = host port = port [result = #Result#]>
<webSocketOpen name = name host = host:port [result = #Result#]>
<webSocketSend socket = socket text = Text [result = #result#]>
<webSocketReceive socket = socket text = #Text# [result = #result#]>
<webSocketClose socket = socket [result = #result#]>

Agument
/tutorial/argument/arg82.wml
Example
<webSocketOpen name = "MySocket" host = "www.webplus.com:80" result = #r#>
<webSocketSend socket = "MySocket" text = #"GET /index.htm" & Chr(13) & Chr(10)# result = #r#>
<webSocketReceive socket = "MySocket" text = #Text#>
<webSocketClose socket = "MySocket">

Exercise
This example opens a socket to search.yahoo.com, port 80. It submits a request to search for the string "TalentSoft" and prints the results returned by the remote machine. It then closes the socket.

You can try out some Web+ code of your own here.

Previous

  Contents   Next

 

Copyright © 2009 Webplus, Inc. (talentsoft). All Rights Reserved.
webmaster@webplus.com