Skip to content

AcceptTCPStream

Narta Xaymar Dirks edited this page Nov 1, 2026 · 6 revisions

Blitz3DBlitzPlusBlitzBasic

AcceptTCPStream

AcceptTCPStream:Int32 tcp_server:Int32
Parameter Mode Type Default Description
tcp_server In Int32 required The server from CreateTCPServer.

Returns: A TCP stream, or 0 when nobody connected.

Description

Takes the next connection that a client made to a TCP server and returns a stream for it. If nobody connected within the accept timeout of TCPTimeouts, which is 0 until you set it, it returns 0, so call it in a loop.

Examples

TCPTimeouts 1000, 1000
server = CreateTCPServer(40751)
client = OpenTCPStream("127.0.0.1", 40751)
connection = 0
For i = 1 To 50
	connection = AcceptTCPStream(server)
	If connection <> 0 Then Exit
	Delay 20
Next
WriteLine client, "hello server"
Print ReadLine$(connection)
CloseTCPStream client
CloseTCPStream connection
CloseTCPServer server
hello server

Related Commands

CloseTCPServer, CloseTCPStream, CloseUDPStream, CreateUDPStream, GetTCPStreamAddress, OpenTCPStream, TCPStreamIP, TCPStreamPort

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally