| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>CloseTCPServer serverhandle</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- serverhandle = handle assigned when the server was created.
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- Closes a TCP/IP server previously created with the CreateTCPServer command.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/CloseTCPServer.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; CreateTCPServer, CloseTCPServer, AcceptTCPStream Example
<br />
- ; This code is in two parts, and needs to be run seperately on the same machine
<br />
-
<br />
- ; --- Start first code set ---
<br />
- ; Create a server and listen for push
<br />
-
<br />
- svrGame=CreateTCPServer(8080)
<br />
-
<br />
- If svrGame<>0 Then
<br />
- Print "Server started successfully."
<br />
- Else
<br />
- Print "Server failed to start."
<br />
- End
<br />
- End If
<br />
-
<br />
- While Not KeyHit(1)
<br />
- strStream=AcceptTCPStream(svrGame)
<br />
- If strStream Then
<br />
- Print ReadString$(strStream)
<br />
- Delay 2000
<br />
- End
<br />
- Else
<br />
- Print "No word from Apollo X yet ..."
<br />
- Delay 1000
<br />
- End If
<br />
- Wend
<br />
-
<br />
- End
<br />
-
<br />
- ; --- End first code set ---
<br />
-
<br />
-
<br />
- ; --- Start second code set ---
<br />
- ; Copy this code to another instance of Blitz Basic
<br />
- ; Run the above code first, then run this ... they will 'talk'
<br />
-
<br />
- ; Create a Client and push data
<br />
-
<br />
- strmGame=OpenTCPStream("127.0.0.1",8080)
<br />
-
<br />
- If strmGame<>0 Then
<br />
- Print "Client Connected successfully."
<br />
- Else
<br />
- Print "Server failed to connect."
<br />
- WaitKey
<br />
- End
<br />
- End If
<br />
-
<br />
- ; write stream to server
<br />
- WriteString strmGame,"Mission Control, this is Apollo X ..."
<br />
- Print "Completed sending message to Mission control..."
<br />
-
<br />
- ; --- End second code set ---
<br />
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=CloseTCPServer&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|