OpenTCPStream.htm 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>OpenTCPStream (ip$,port)</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. ip$=Address of stream <br />
  13. port=TCP/IP Port Number
  14. </td>
  15. </tr>
  16. </table>
  17. <h1>Description</h1>
  18. <table>
  19. <tr>
  20. <td>
  21. Use this command to open up a TCP/IP stream to the designated server and port. If the open command was successful, the command returns a stream handle. Otherwise it returns 0. <br />
  22. <br />
  23. You can use this for a multitude of different 'internet' options. Obviously to contact a TCP/IP host outside your own network, you'll need to be connected to the Internet. <br />
  24. <br />
  25. The IP address can be in the form of 1.2.3.4 or "www.domain.com".
  26. </td>
  27. </tr>
  28. </table>
  29. <h1><a href=../2d_examples/OpenTCPStream.bb>Example</a></h1>
  30. <table>
  31. <tr>
  32. <td>
  33. ; OpenTCPStream/CloseTCPStream Example <br />
  34. <br />
  35. Print "Connecting..." <br />
  36. tcp=OpenTCPStream( "www.blitzbasement.com",80 ) <br />
  37. <br />
  38. If Not tcp Print "Failed.":WaitKey:End <br />
  39. <br />
  40. Print "Connected! Sending request..." <br />
  41. <br />
  42. WriteLine tcp,"GET http://www.blitzbasement.com HTTP/1.0" <br />
  43. WriteLine tcp,Chr$(10) <br />
  44. <br />
  45. If Eof(tcp) Print "Failed.":WaitKey:End <br />
  46. <br />
  47. Print "Request sent! Waiting for reply..." <br />
  48. <br />
  49. While Not Eof(tcp) <br />
  50. Print ReadLine$( tcp ) <br />
  51. Wend <br />
  52. <br />
  53. If Eof(tcp)=1 Then Print "Success!" Else Print "Error!" <br />
  54. <br />
  55. CloseTCPStream tcp <br />
  56. <br />
  57. WaitKey <br />
  58. End <br />
  59. </td>
  60. </tr>
  61. </table>
  62. <br>
  63. <a target=_top href=../index.htm>Index</a><br>
  64. <br>
  65. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=OpenTCPStream&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  66. </html>