View source code
Display the source code in std/socket.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Class std.socket.TcpSocket
TcpSocket
is a shortcut class for a TCP Socket.
Constructors
Name | Description |
---|---|
this
|
Constructs a blocking TCP Socket. |
this
|
Constructs a blocking IPv4 TCP Socket. |
this
|
Constructs a blocking TCP Socket and connects to an Address .
|
Fields
Name | Type | Description |
---|---|---|
_blocking
|
bool | Property to get or set whether the socket is blocking or nonblocking. |
Properties
Name | Type | Description |
---|---|---|
addressFamily [get]
|
AddressFamily | Get the socket's address family. |
blocking [get, set]
|
bool | Get/set socket's blocking flag. |
handle [get]
|
std | Get underlying socket handle. |
hostName [get]
|
string | |
isAlive [get]
|
bool | Property that indicates if this is a valid, alive socket. |
localAddress [get]
|
Address | Local endpoint Address .
|
remoteAddress [get]
|
Address | Remote endpoint Address .
|
Methods
Name | Description |
---|---|
accept
|
Accept an incoming connection. If the socket is blocking, accept
waits for a connection request. Throws SocketAcceptException if
unable to accept. See accepting for use with derived classes.
|
bind
|
Associate a local address with this socket. |
close
|
Immediately drop any connections and release socket resources.
Calling shutdown before close is recommended for
connection-oriented sockets. The Socket object is no longer
usable after close .
Calling shutdown() before this is recommended
for connection-oriented sockets.
|
connect
|
Establish a connection. If the socket is blocking, connect waits for the connection to be made. If the socket is nonblocking, connect returns immediately and the connection attempt is still in progress. |
factory
|
Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor. |
getErrorText
|
Get a text description of this socket's error status, and clear the socket's error status. |
getOption
|
Get a socket option. |
getOption
|
Common case of getting integer and boolean options. |
getOption
|
Get the linger option. |
getOption
|
Get a timeout (duration) option. |
listen
|
Listen for an incoming connection. bind must be called before you
can listen . The backlog is a request of how many pending
incoming connections are queued until accept ed.
|
opCmp
|
Compare with another Object obj. |
opEquals
|
Test whether this is equal to o .
The default implementation only compares by identity (using the is operator).
Generally, overrides for opEquals should attempt to compare objects by their contents.
|
receive
|
Receive data on the connection. If the socket is blocking, receive
waits until there is data to be received.
|
receiveFrom
|
Receive data and get the remote endpoint Address .
If the socket is blocking, receiveFrom waits until there is data to
be received.
|
select
|
Wait for a socket to change status. A wait timeout of Duration or
TimeVal , may be specified; if a timeout is not specified or the
TimeVal is null , the maximum timeout is used. The TimeVal
timeout has an unspecified value when select returns.
|
send
|
Send data on the connection. If the socket is blocking and there is no
buffer space left, send waits.
|
sendTo
|
Send data to a specific destination Address. If the destination address is
not specified, a connection must have been made and that address is used.
If the socket is blocking and there is no buffer space left, sendTo waits.
|
setKeepAlive
|
Enables TCP keep-alive with the specified parameters. |
setOption
|
Set a socket option. |
setOption
|
Common case for setting integer and boolean options. |
setOption
|
Set the linger option. |
setOption
|
Sets a timeout (duration) option, i.e. SocketOption or
RCVTIMEO . Zero indicates no timeout.
|
shutdown
|
Disables sends and/or receives. |
toHash
|
Compute hash function for Object. |
toString
|
Convert Object to a human readable string. |
accepting
|
Called by accept when a new Socket must be created for a new
connection. To use a derived class, override this method and return an
instance of your class. The returned Socket 's handle must not be
set; Socket has a protected constructor this() to use in this
situation.
|
createAddress
|
Can be overridden to support other addresses. |
Authors
Christopher E. Miller, David Nadlinger, Vladimir Panteleev
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.