Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

ClientSocket Class

Represents a single socket connection to a client IP address.

When a NetServer accepts a TCP connection, it creates a new ClientSocket object for that connection. This is a very simple class that assists in the management of I/O between the accepted client and the server.

Structure

The ClientSocket class consists of the following fields:

Access
NameTypeComment
 Client*NetClientParent client object (IP address).
 ClientDataAPTRAvailable for client data storage.
 ConnectTimeINT64System time for the creation of this socket.
 Next*ClientSocketNext socket in the chain.
 Prev*ClientSocketPrevious socket in the chain.
 StateNTCThe current connection state of the ClientSocket object.

The State reflects the connection state of this accepted client socket. If the parent NetServer has a #Feedback function, it will be called automatically whenever the state is changed.

NameDescription
NTC::CONNECTEDThere is an active connection at present.
NTC::CONNECTINGA connection is being established.
NTC::DISCONNECTEDThere is no connection.
NTC::HANDSHAKINGAn SSL connection is being established.
NTC::MULTISTATEA NetServer reports MULTISTATE because accepted ClientSocket objects track their own states.
NTC::RESOLVINGThe host name is being resolved.

Actions

The following actions are currently supported:

DeactivateDisconnects the socket and changes the State to DISCONNECTED.
ReadRead incoming data from a client socket.
ERR acRead(*Object, std::span<int8_t> Buffer, INT *Result)
ParameterDescription
BufferA mutable buffer that will receive the data.
ResultThe Read action will write this parameter with the total number of bytes read into the Buffer.

The Read() action will read incoming data from the socket and write it to the provided buffer. If the socket connection is safe, success will always be returned by this action regardless of whether or not data was available. Almost all other return codes indicate permanent failure, and the socket connection will be closed when the action returns.

Error Codes
OkayRead successful (if no data was on the socket, success is still indicated).
FailedA permanent failure has occurred and socket has been closed.
ArgsInvalid arguments passed to function
DisconnectedThe socket connection is closed.
NullArgsFunction call missing argument value(s)
WriteWrites data to the socket.
ERR acWrite(*Object, std::span<const int8_t> Buffer, INT *Result)
ParameterDescription
BufferA buffer containing the data that will be written to the object.
ResultThis parameter with be updated with the total number of bytes written from the Buffer.

Write raw data to a client socket with this action. Write connections are buffered, so any data overflow generated in a call to this action will be buffered into a software queue. Resource limits placed on the software queue are governed by the NetSocket⇒MsgLimit value.

Assuming no errors occur, the reported result will always reflect the length of the incoming buffer.

ClientSocket class documentation © Paul Manias © 2005-2026

NTC Type

NetSocket states

NameDescription
NTC::CONNECTEDThere is an active connection at present.
NTC::CONNECTINGA connection is being established.
NTC::DISCONNECTEDThere is no connection.
NTC::HANDSHAKINGAn SSL connection is being established.
NTC::MULTISTATEA NetServer reports MULTISTATE because accepted ClientSocket objects track their own states.
NTC::RESOLVINGThe host name is being resolved.
ClientSocket module documentation © Paul Manias © 2005-2026