Instance methods
accept
Answers a new socket by accepting a connection on the receiver.
Extracts the first connection on the queue of pending connections and creates a new socket with the same properties as the receiver. If the listen queue has no connection requests the current process will block until a connection is present, or if the receiver is non blocking, it will return an EWOULDBLOCK error code.
If possible, an accept on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking accept in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
See accept: for the use of the optional parameter aSocketAddress. accept will not solicit the address of the connecting socket at acceptance time. However, you can send getPeerName to obtain the address later.
The new socket cannot accept more connections. However, the receiver remains open and can accept more connections.
If the accept operation is unsucessful, it will return an error if one or more of the following is true: ENOTINITIALISED, ENETDOWN, EBADF, ENOTSOCK, EOPNOTSUPP, EWOULDBLOCK, EINPROGRESS, EINTR, EINVAL, EMFILE, ENOBUFS, EACCES. For detailed information on these errors, see Error values.
accept: aSocketAddress
Answers a new socket by accepting a connection on the receiver and updating the socket address information.
aSocketAddress
Socket address of connecting socket.
The parameter aSocketAddress is a new instance of SciSocketAddress. If an accept is successful aSocketAddress will then contain the address of the connecting socket. If you want a nil aSocketAddress, then use accept.
Extracts the first connection on the queue of pending connections and creates a new socket with the same properties as the receiver. If the listen queue has no connection the current process will block until a connection is present, or if the receiver is non blocking, it returns an EWOULDBLOCK error code.
If possible, an accept: on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking accept in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
The new socket cannot accept more connections. The receiver remains open and can accept more connections.
If the accept: operation is unsucessful, it will return an error if one or more of the following is true: ENOTINITIALISED, ENETDOWN, EBADF, ENOTSOCK, EOPNOTSUPP, EWOULDBLOCK, EINPROGRESS, EINTR, EINVAL, EMFILE, ENOBUFS, EACCES. For detailed information on these errors, see Error values.
bind: aSocketAddress
Binds a socket address to a socket. Assigns aSocketAddress to an unbound socket.
aSocketAddress
Socket address to be bound
The parameter aSocketAddress contains a valid address, port and family.
If any of the following are true, the bind: aSocketAddress operation returns an error: ENOTINITIALISED, ENETDOWN, EBADF, ENOTSOCK, EAFNOSUPPORT, EADDRNOTAVAIL, EADDRINUSE, EINVAL, ENOBUFS, EACCES. For detailed information on these errors, see Error values.
close
Closes the receiver (socket).
Closes and releases the socket. The actual close is affected by the socket options SOLINGER and SODONTLINGER. If SOLINGER has a timeout interval, then a hard or abortive close is performed even if queued data is unsent or unacknowledged. If SOLINGER is non-zero on a blocking socket, this operation blocks the current process until the remaining data is sent or the timeout expires. If the socket is set to non-blocking an error EWOULDBLOCK is returned.
If SODONTLINGER is set on a stream socket, the operation will return immediately but data queued for transmission will still be sent. Note that this will delay releasing the socket and the socket being available for an arbitrary period.
If possible, a close on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking close in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
If any of the following occurs, the close operation returns an error: ENOTINITIALISED, ENETDOWN, EBADF, ENOTSOCK, EINTR, EINPRORESS, EWOULDBLOCK, EACCES. For detailed information on these errors, see Error values.
connect: aSocketAddress
Connects two sockets.
aSocketAddress
Specifies the socket address of the targeted socket.
Creates a connection between the receiver and the socket with socket address aSocketAddress. Both sockets must use the same address format and protocol. If a socket is unbound the system automatically binds the socket.
If the receiver is blocking, the operation may block at the current Smalltalk process level until the connection is completed. If the receiver is non-blocking, the error code EWOULDBLOCK may be returned.
If possible, a connect on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking connect in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
If the receiver is a SOCKDGRAM, the connect operation establishes the peer address. The peer address identifies the socket where all datagrams are sent on subsequent sends.
If the initiating socket is SOCKSTREAM, the connect operation attempts to make a connection to the socket specified by the parameter aSocketAddress.
If any of the following occurs, the connect: aSocketAddress operation returns an error: ENOTINITIALISED, ENETDOWN, EBADF, ENOTSOCK, EADDRNOTAVAIL, EDESTADDREQ, EAFNOSUPPORT, ENETDOWN, EISCONN, ETIMEDOUT, ECONNREFUSED, ENETUNREACH, EADDRINUSE, ENOBUFS, EMFILE, EINPRORESS, EINVAL, EINTR, EWOULDBLOCK, EACCES. For detailed information on these errors, see Error values.
getSockOpt: optionName
Answer the value of the specified option.
optionName
specifies the option for which information is to be retrieved. Currently, only socket level options are supported.
Here are the names of the options that are typically supported by the underlying TCP/IP stack:
SODEBUG
SOACCEPTCONN
SOTYPE
SOLINGER
SOREUSEADDR
SOKEEPALIVE
SOSNDBUF
SODONTROUTE
SOBROADCAST
SOERROR
SODONTLINGER
SORCVBUF

The operation answers a boolean for the following options:
SOACCEPTCONN,
SODEBUG,
SOREUSEADDR,
SODONTROUTE,
SOKEEPALIVE,
SOBROADCAST,
SODONTLINGER
The operation anwers an integer for the following options.
SOERROR,
SOSNDBUF,
SOTYPE,
SORCVBUF
The operation answers a two entry array for the SOLINGER option. The first entry is a boolean and the second is an integer.
ioctl: controlOperation parameter: aParameter
Performs the control operation on the receiver. Returns the number of bytes for FIONREAD function
The ioctl: operation performs a variety of control operations on the receiver.
Note:
Note that all sockets are created as blocking by default (see socket). The blocking/non-blocking attribute can be changed at any time with the ioctl: operation. Operations on blocking sockets that will block (e.g., send, sendTo, recv, recvFrom, accept, connect and close) must be made from a Smalltalk process that can afford to block.
Note:
Blocking calls from the UI Process is not recommended as the User Interface will not available for the duration of the call. Blocking calls from the context of a callback are not allowed and will return the error EACCES.
controlOperation
Specifies the control function to be performed. The following are the control operations supported by a typical operating system implementation of ioctl:
FIONREAD
Get number bytes to read that are available on the socket
FIONBIO
Non-Blocking mode is set or reset based on aParameter.
aParameter
If controlOperation is FIONBIO, a true sets the socket to be non-blocking. A false or nil sets the socket to be blocking. The default mode is blocking.
The ioctl: operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, EBADF, EINTR, EINVAL, ENOTSOCK, EINPROGRESS.. For detailed information on these errors, see Error values.
listen: backLog
Listens for socket connections and limits the backlog of incoming connections.
The listen operation performs the following:
a. Identifies the socket that receives the connections.
b. Marks the socket as accepting connections.
c. Limits the number of outstanding connection requests in the system queue.
The maximum queue length that the listen operation can specify is ten.
backLog
Specifies the maximum number of outstanding connection requests.
The listen: backLog operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, EADDRINUSE, EINVAL, EISCONN, EMFILE, ENOBUFS, EINPROGRESS, EBADF, ENOTSOCK, EOPNOTSUPP, ECONNREFUSED.. For detailed information on these errors, see Error values.
recv: aBuffer length: length startingAt: index flags: flags
Receives data from connected sockets.
The recv operation receives data from a connected socket.
The recv operation returns the length of the data received. If a data is too long to fit in the supplied buffer, excess bytes may be truncated if the receiver is a datagram socket.
If no data is available at the socket, the recv operation blocks the current process while waiting for data to arrive, unless the socket is non blocking. If a socket is non blocking, the operation returns an error (EWOULDBLOCK).
If possible, a recv on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking recv in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
If the socket is of type SOCKSTREAM and the remote side has shut down the connection gracefully, the recv operation completes with 0 bytes received.
aBuffer
A byte array created to hold the received data.
length
Requested number of bytes to receive. The length must not exceed the size of aBuffer plus the index - 1.
index
Points to the first position in aBuffer to receive in. The index is 1 relative (the first position is 1).
flags
Controls the data reception. Currently, only the following value is supported:
MSGPEEK
Peeks at incoming message. The data is treated as unread, and the next recv operation still returns this data.
Note:
MSGPEEK may not be supported on all TCP/IP stacks.
The recv: aBuffer length: length startingAt: index flags: flags operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, ENOTCONN, EINPROGRESS, EOPNOTSUPP, ESHUTDOWN, EBADF, ENOTSOCK, EWOULDBLOCK, EMSGSIZE, EINVAL, ECONNABORTED, ECONNRESET, EINTR, EACCES. For detailed information on these errors, see Error values.
recvAll: aBuffer length: length startingAt: index flags: flags
Receives data from connected sockets.
The recvAll operation receives data from a connected socket. If multiple receives are required to receive the length, the message will be broken into message segments and received. The recvAll operation will block at the current Smalltalk process level until the operation is completed or returns with an error code. A recvAll in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
The recvAll operation returns a 0 if successfully received length bytes or returns a SciError.
If the socket is of type SOCKSTREAM and the remote side has shut down the connection gracefully, the recvAll operation completes with 0 bytes received.
aBuffer
A byte array created to hold the received data
length
Requested number of bytes to receive. The length must not exceed the size of aBuffer plus index - 1.
index
Points to the first position in aBuffer to receive in. The index is 1 relative (the first position is 1).
flags
Controls the data reception. Currently, only the following value is supported:
MSGPEEK
Peeks at incoming message. The data is treated as unread, and the next recv operation still returns this data.
Note:
MSGPEEK may not be supported on all TCP/IP stacks.
The recvAll: aBuffer length: length startingAt: index flags: flags operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, ENOTCONN, EINPROGRESS, EOPNOTSUPP, ESHUTDOWN, EBADF, ENOTSOCK, EWOULDBLOCK, EMSGSIZE, EINVAL, ECONNABORTED, ECONNRESET, EINTR, EACCES. For detailed information on these errors, see Error values.
recvFrom: aBuffer length: length startingAt: index flags: flags from: aSocketAddress
Receives data from sockets.
The recvFrom operation allows an application to receive data from connected and unconnected sockets. The recvFrom operation specifies the source of the data to be received allowing the data to be received from unconnected sockets.
If no data is available at the socket, the recvFrom operation blocks the current process while waiting for data to arrive, unless the socket is non blocking. If a socket is non blocking, the operation returns an error (EWOULDBLOCK).
If possible, a recvFrom on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking recvFrom in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
The recvFrom operation returns the length of the received data. For a datagram socket, if data is too long to fit in the supplied buffer, excess bytes may be truncated depending on the type of socket, and an error code is returned.
aSocketAddress
Updated with the address of the source of the data
aBuffer
Byte array created to hold the received data
length
Requested number of bytes to receive. The length must not exceed the size of aBuffer plus the index - 1.
index
Points to the first position in aBuffer to receive. The index is 1 relative (the first position is 1).
flags
Controls the data reception. Currently, only the following value is supported:
MSGPEEK
Peeks at incoming message. The data is treated as unread, and the next recv operation still returns this data.
Note:
MSGPEEK may not be supported on all TCP/IP stacks.
The recvFrom: aBuffer length: length startingAt: index flags: flags from: aSocketAddress operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, ENOTCONN, EINPROGRESS, EOPNOTSUPP, ESHUTDOWN, ENOTSOCK, EWOULDBLOCK, EMSGSIZE, EINVAL, ECONNABORTED, ECONNRESET, EINTR, EBADF, EACCES. For detailed information on these errors, see Error values.
send: aBuffer length: length startingAt: index flags: flags
Sends data to a connected socket.
This operation sends data only when the socket is connected. The sendTo: operation can be used with unconnected or connected sockets.
Specify the length of the data with the length parameter. If the receiver is a datagram socket and the data is too long to pass through the underlying protocol, the system returns an error and does not transmit the data. If the receiver is a stream socket, the receiver answers the number of transmitted bytes.
If no buffer space is available within the transport system, the send operation blocks the current process while waiting for buffer space, unless the socket is non blocking. If a socket is non blocking, the operation returns an error (EWOULDBLOCK).
If possible, a send on a blocking socket will block the current Smalltalk process. (i.e., If the current process is in a callback, an EACCES error is returned.) A blocking send in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
aBuffer
Byte array containing the data to be sent.
length
Length of the data to be sent in bytes. The length must not exceed the size of aBuffer plus the index - 1.
index
Points to the first position in aBuffer to send from. The index is 1 relative (the first position is 1).
flags
Controls the message transmission and is formed by optionally including the following value:
MSGDONTROUTE
Sends without using routing tables.
The send: aBuffer length: length startingAt: index flags: flags operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, ENETRESET, ENOTCONN, ENOBUFS, EINPROGRESS, EOPNOTSUPP, ESHUTDOWN, EBADF, ENOTSOCK, EWOULDBLOCK, EMSGSIZE, EINVAL, ECONNABORTED, ECONNRESET, EINTR, EACCES. For detailed information on these errors, see Error values.
sendAll: aBuffer length: length startingAt: index flags: flags
Sends data to a connected socket.
This operation sends length bytes of data from aBuffer starting at index. If multiple sends are required the message will be broken into message segments and sent. The sendAll: operation will block at the current Smalltalk process level until the operation is completed or returns with an error code. A sendAll: in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
The socket must be a connected socket. The sendTo: operation must be used with unconnected sockets.
aBuffer
The parameter is a byte array containing the data to be sent.
length
Length of the data to be sent in bytes. The length must not exceed the size of aBuffer plus the index - 1.
index
1 based offset into the buffer of the first byte to send.
flags
Controls the message transmission and is formed optionally including the following value:
MSGDONTROUTE
Sends without using routing tables
The sendAll: aBuffer length: length startingAt: index flags: flags operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, ENETRESET, ENOTCONN, ENOBUFS, EINPROGRESS, EOPNOTSUPP, ESHUTDOWN, EBADF, ENOTSOCK, EWOULDBLOCK, EINVAL, ECONNABORTED, ECONNRESET, EINTR, EACCES. For detailed information on these errors, see Error values.
sendTo: aBuffer length: length startingAt: index flags: flags to: aSocketAddress
Sends data through a socket to a specific socket.
The sendTo operation allows an application program to send messages through an unconnected socket by specifying a destination aSocketAddress. For stream sockets the aSocketAddress parameter is ignored.
Specify the length of the data with the length parameter. If the receiver is a datagram socket and the data is too long to pass through the underlying protocol, the system returns an error and does not transmit the data. If the receiver is a stream socket, the receiver answers the number of transmitted bytes.
If no buffer space is available within the transport system, the sendTo operation blocks the current process while waiting for buffer space (the blocking occurs at the current Smalltalk process level), unless the socket is non blocking. If a socket is non blocking, the operation returns an error (EWOULDBLOCK).
If possible, a sendTo on a blocking socket will block the current Smalltalk process. (If the current process is in a callback, an EACCES error is returned.) A blocking sendTo in the context of the UI Process is not recommended as it will disable the User Interface for the duration of the blocking call.
To broadcast on a socket, first issue a setSockOpt operation using the SOBROADCAST option to gain broadcast permissions. (Broadcast only on datagram sockets.)
aBuffer
Byte array containing the data to be sent.
length
Length of the data to be sent in bytes. Thelength must not exceed the size of aBuffer plus the index - 1. If the data is too long to pass through the underlying protocol, the error EMSGSIZE is returned and the data is not transmitted.
index
Points to the first position in aBuffer to send from. The index is 1 relative (the first position is 1).
flags
Controls the message transmission and is formed by optionally including the following value:
MSGDONTROUTE
Send without using routing tables.
The sendTo: aBuffer length: length startingAt: index flags: flags to: aSocketAddress operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, ENETRESET, ENOTCONN, ENOBUFS, EINPROGRESS, EOPNOTSUPP, EAFNOSUPPORT, ESHUTDOWN, EBADF, ENOTSOCK, EWOULDBLOCK, EMSGSIZE, EINVAL, ECONNABORTED, ECONNRESET, EINTR, EADDRNOTAVAIL, EDESTADDREQ, ENETUNREACH, EACCES. For detailed information on these errors, see Error values.
The shutDown: mode operation is unsucessful if any of the following errors occur: ENOTINITIALISED, ENETDOWN, EINVAL, EINPROGRESS, ENOTCONN, EBADF, ENOTSOCK. For detailed information on these errors, see Error values.
setSockOpt: optionName optionValue: optionValue
Allows an application to set a socket option.
optionName
See getSockOpt: for the options that are typically supported by the underlying TCP/IP stack.
optionValue
See getSockOpt: for the values which the options take.
Last modified date: 01/29/2015