Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

BlitzMax/Modules/Networking/Sockets

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Functions CreateUDPSocket Function CreateUDPSocket:TSocket() Description: Create a UDP socket Returns: A new socket Information: The new socket is not bound to any local or remote address. CreateTCPSocket Function CreateTCPSocket:TSocket() Description: Create a TCP socket Returns: A new socket Information: The new socket is not bound to any local or remote address. CloseSocket Function CloseSocket( socket:TSocket ) Description: Close a socket Information: All sockets should eventually be closed. Once closed, a socket can no longer be used. BindSocket Function BindSocket( socket:TSocket,localPort ) Description: Bind a socket to a local port Returns: True if successful, otherwise false Information: If localPort is 0, a new local port will be allocated. If localPort is not 0, BindSocket will fail if there is already an application bound to localPort. ConnectSocket Function ConnectSocket( socket:TSocket,remoteIp,remotePort ) Description: Connect a socket to a remote ip and port Returns: True if successful, otherwise false Information: For both UDP and TCP sockets, ConnectSocket will fail if the specified ip address could not be reached. In the case of TCP sockets, ConnectSocket will also fail if there is no application listening at the remote port. SocketListen Function SocketListen( socket:TSocket,backlog=0 ) Description: Start listening at a socket Information: The specified socket must be a TCP socket, and must already be bound to a local port. SocketAccept Function SocketAccept:TSocket( socket:TSocket,timeout=0 ) Description: Accept new connections on a listening socket Returns: A new socket, or Null if no connection was made in the specified timeout Information: The specified socket must be a TCP socket, and must be listening. SocketConnected Function SocketConnected( socket:TSocket ) Description: Get socket connection status Returns: True if socket is connected Information: SocketConnected allows you to determine if a TCP connection is still alive or has been remotely closed. SocketConnected should only be used with TCP sockets that have already connected via ConnectSocket or SocketAccept. SocketReadAvail Function SocketReadAvail( socket:TSocket ) Description: Get number of bytes available for reading from a socket Returns: Number of bytes that may be read without causing the socket to block SocketLocalIP Function SocketLocalIP( socket:TSocket ) Description: Get local ip of a socket SocketLocalPort Function SocketLocalPort( socket:TSocket ) Description: Get local port of a socket SocketRemoteIP Function SocketRemoteIP( socket:TSocket ) Description: Get remote ip of a socket SocketRemotePort Function SocketRemotePort( socket:TSocket ) Description: Get remote port of a socket DottedIP Function DottedIP$( ip ) Description: Convert an ip address to a dotted string Returns: Dotted string version of ip address HostIp Function HostIp( HostName$,index=0 ) Description: Convert a host name to an ip address Returns: Host ip address, or 0 if host not found HostIps Function HostIps:Int[]( HostName$ ) Description: Get all ip addresses for a host name Returns: Array of host ips, or Null if host not found HostName Function HostName$( HostIp ) Description: Convert a host ip address to a name Returns: Name of host, or Null if host not found